Skip to content

Commit

Permalink
Pass rootMode from @babel/node. (#9078)
Browse files Browse the repository at this point in the history
* Pass `root-mode` from `@babel/node`.

* Filter `babelOptions`.
  • Loading branch information
wtgtybhertgeghgtwtg authored and loganfsmyth committed Nov 29, 2018
1 parent 0859535 commit c4d6f6d
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions packages/babel-node/src/_babel-node.js
Expand Up @@ -52,14 +52,19 @@ program.option(
"The name of the 'env' to use when loading configs and plugins. " +
"Defaults to the value of BABEL_ENV, or else NODE_ENV, or else 'development'.",
);
commander.option(
"--root-mode [mode]",
"The project-root resolution mode. " +
"One of 'root' (the default), 'upward', or 'upward-optional'.",
);
program.option("-w, --plugins [string]", "", collect);
program.option("-b, --presets [string]", "", collect);

program.version(pkg.version);
program.usage("[options] [ -e script | script.js ] [arguments]");
program.parse(process.argv);

register({
const babelOptions = {
caller: {
name: "@babel/node",
},
Expand All @@ -70,12 +75,21 @@ register({
presets: program.presets,
configFile: program.configFile,
envName: program.envName,
rootMode: program.rootMode,

// Commander will default the "--no-" arguments to true, but we want to
// leave them undefined so that @babel/core can handle the
// default-assignment logic on its own.
babelrc: program.babelrc === true ? undefined : program.babelrc,
});
};

for (const key of Object.keys(babelOptions)) {
if (babelOptions[key] === undefined) {
delete babelOptions[key];
}
}

register(babelOptions);

const replPlugin = ({ types: t }) => ({
visitor: {
Expand Down

0 comments on commit c4d6f6d

Please sign in to comment.