babel/scripts/integration-tests/utils/bump-babel-dependencies.js
Huáng Jùnliàng 1a1454328b
chore: replace yarn-upgrade by bump-babel-dependencies in e2e tests (#11021)
* chore: pin yarn version in e2e vue tests

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

* chore: update e2e-cra test
2020-01-17 07:55:29 -05:00

30 lines
775 B
JavaScript

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));
}