diff --git a/scripts/integration-tests/publish-local.sh b/scripts/integration-tests/publish-local.sh index 6e82395d291d..1dd7c1b01a3c 100755 --- a/scripts/integration-tests/publish-local.sh +++ b/scripts/integration-tests/publish-local.sh @@ -25,6 +25,17 @@ initializeE2Egit yarn +# Does not trap on error +node --experimental-fetch scripts/integration-tests/utils/e2e-check.js && :; ret=$? + +if [ $ret -eq 10 ]; then + cleanup + exit 0 +elif [ $ret -ne 0 ]; then + cleanup + exit 1 +fi + startLocalRegistry "$PWD"/scripts/integration-tests/verdaccio-config.yml loginLocalRegistry diff --git a/scripts/integration-tests/utils/e2e-check.js b/scripts/integration-tests/utils/e2e-check.js new file mode 100644 index 000000000000..d45d88e84378 --- /dev/null +++ b/scripts/integration-tests/utils/e2e-check.js @@ -0,0 +1,21 @@ +import fs from "fs"; + +const resp = await fetch( + "https://raw.githubusercontent.com/babel/babel/main/package.json" +); +const mainRepoPackageJson = await resp.json(); + +if ( + mainRepoPackageJson.version !== + JSON.parse(fs.readFileSync("package.json")).version +) { + if (process.env.GITHUB_REPOSITORY === "babel/babel") { + console.error("The branch is not up to date with main, please rebase"); + process.exitCode = 1; + } else { + console.error( + "The branch is not up to date with main of babel/babel, skipping" + ); + process.exitCode = 10; + } +}