Skip to content

Commit

Permalink
chore: replace yarn-upgrade by bump-babel-dependencies in e2e tests (#…
Browse files Browse the repository at this point in the history
…11021)

* chore: pin yarn version in e2e vue tests

* fix: replace yarn-upgrade by bump-babel-dependencies

* chore: update e2e-cra test
  • Loading branch information
JLHwung committed Jan 17, 2020
1 parent 06dace1 commit 1a14543
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 8 deletions.
6 changes: 3 additions & 3 deletions scripts/integration-tests/e2e-create-react-app.sh
Expand Up @@ -23,9 +23,9 @@ cd tmp/create-react-app || exit

startLocalRegistry "$PWD"/../../verdaccio-config.yml
yarn install
# "yarn upgrade --scope @babel --latest" doesn't seem to work.
# a means "all", while \n is the enter needed to confirm the selection.
printf "a\n" | yarn upgrade-interactive --scope @babel --latest
node "$PWD"/../../utils/bump-babel-dependencies.js
yarn lerna exec -- node "$PWD"/../../utils/bump-babel-dependencies.js
yarn install

# Test
CI=true yarn test
Expand Down
8 changes: 3 additions & 5 deletions scripts/integration-tests/e2e-vue-cli.sh
Expand Up @@ -23,11 +23,9 @@ cd tmp/vue-cli || exit

startLocalRegistry "$PWD"/../../verdaccio-config.yml
yarn install
# Workaround https://github.com/yarnpkg/yarn/issues/7797
yarn add --dev -W @babel/core
# "yarn upgrade --scope @babel --latest" doesn't seem to work.
# a means "all", while \n is the enter needed to confirm the selection.
printf "a\n" | yarn upgrade-interactive --scope @babel --latest
node "$PWD"/../../utils/bump-babel-dependencies.js
yarn lerna exec -- node "$PWD"/../../utils/bump-babel-dependencies.js
yarn install

# Test
CI=true yarn test -p babel,babel-preset-app
Expand Down
29 changes: 29 additions & 0 deletions scripts/integration-tests/utils/bump-babel-dependencies.js
@@ -0,0 +1,29 @@
const fs = require("fs");
const path = require("path");
const cwd = process.cwd();
const packageJSONPath = path.resolve(cwd, "./package.json");
const content = JSON.parse(fs.readFileSync(packageJSONPath));

let bumped = false;
function bumpBabelDependency(dependencies) {
for (const dep of Object.keys(dependencies)) {
if (dep.startsWith("@babel/")) {
dependencies[dep] = "latest";
bumped = true;
}
}
}

if ("peerDependencies" in content) {
bumpBabelDependency(content.peerDependencies);
}
if ("devDependencies" in content) {
bumpBabelDependency(content.devDependencies);
}
if ("dependencies" in content) {
bumpBabelDependency(content.dependencies);
}

if (bumped) {
fs.writeFileSync(packageJSONPath, JSON.stringify(content, undefined, 2));
}

0 comments on commit 1a14543

Please sign in to comment.