Files
babel/scripts/integration-tests/utils/bump-babel-dependencies.js
liuxingbaoyuandGitHub ca6b915563 chore: expand prettier-e2e test and update typings/deps (#14779)
* chore

* test

* test

* update plugin-transform-typescript
2022-07-26 09:15:28 -04:00

33 lines
905 B
JavaScript

import fs from "fs";
import path from "path";
const cwd = process.cwd();
const packageJSONPath = path.resolve(cwd, "./package.json");
const content = JSON.parse(fs.readFileSync(packageJSONPath));
let bumped = false;
function bumpBabelDependency(type, version) {
const dependencies = content[type];
for (const dep of Object.keys(dependencies)) {
if (dep.startsWith("@babel/") && !dependencies[dep].includes(":")) {
dependencies[dep] = version;
console.log(`Bumped ${type}:${dep} to ${version}`);
bumped = true;
}
}
}
if ("peerDependencies" in content) {
bumpBabelDependency("peerDependencies", "*");
}
if ("devDependencies" in content) {
bumpBabelDependency("devDependencies", "latest");
}
if ("dependencies" in content) {
bumpBabelDependency("dependencies", "latest");
}
if (bumped) {
fs.writeFileSync(packageJSONPath, JSON.stringify(content, undefined, 2));
}