Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update all babelrc's in the cwd, if not a monorepo #14

Merged
merged 2 commits into from
Feb 21, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion bin/babel-upgrade
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,27 @@

const path = require('path');
const { isAcceptedNodeVersion, writePackageJSON, writeBabelRC } = require("../src");
const globby = require('globby');
const cwd = process.cwd();

if (!isAcceptedNodeVersion()) {
throw new Error("Babel 7 will only support Node 4 and higher");
}

// TOOD: allow passing a specific path
writeBabelRC(path.join(cwd, '.babelrc'));
(async () => {
// account for nested babelrc's
const paths = await globby(['**/.babelrc', '!./node_modules/**']);
const packages = await globby(['**/package.json', '!./node_modules/**']);

// if not a monorepo
if (packages.length === 1) {
if (paths.length > 1) {
console.log("We suggest using the new 'overrides' option instead of nested .babelrc's, can check out http://new.babeljs.io/docs/en/next/babelrc.html#overrides");
}
paths.forEach(p => writeBabelRC(p));
}
})();

// TOOD: allow passing a specific path
writePackageJSON();
Expand Down
Loading