add --config-file option to CLI to pass in .babelrc location (#6133)
This commit is contained in:
parent
7e726a81e6
commit
63baaa7148
@ -48,6 +48,7 @@ commander.option(
|
|||||||
"comma-separated list of plugin names",
|
"comma-separated list of plugin names",
|
||||||
collect,
|
collect,
|
||||||
);
|
);
|
||||||
|
commander.option("--config-file [path]", "Path a to .babelrc file to use");
|
||||||
|
|
||||||
// Basic file input configuration.
|
// Basic file input configuration.
|
||||||
commander.option("--source-type [script|module]", "");
|
commander.option("--source-type [script|module]", "");
|
||||||
@ -200,6 +201,10 @@ if (errors.length) {
|
|||||||
//
|
//
|
||||||
|
|
||||||
const opts = commander.opts();
|
const opts = commander.opts();
|
||||||
|
//the configFile CLI option maps to the extends option in the node API
|
||||||
|
if (opts.configFile) {
|
||||||
|
opts.extends = opts.configFile;
|
||||||
|
}
|
||||||
|
|
||||||
// Delete options that are specific to babel-cli and shouldn't be passed to babel-core.
|
// Delete options that are specific to babel-cli and shouldn't be passed to babel-core.
|
||||||
delete opts.version;
|
delete opts.version;
|
||||||
@ -210,6 +215,7 @@ delete opts.outFile;
|
|||||||
delete opts.outDir;
|
delete opts.outDir;
|
||||||
delete opts.copyFiles;
|
delete opts.copyFiles;
|
||||||
delete opts.quiet;
|
delete opts.quiet;
|
||||||
|
delete opts.configFile;
|
||||||
|
|
||||||
// Commander will default the "--no-" arguments to true, but we want to leave them undefined so that
|
// 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.
|
// babel-core can handle the default-assignment logic on its own.
|
||||||
|
|||||||
3
packages/babel-cli/test/.othername_babelrc
Normal file
3
packages/babel-cli/test/.othername_babelrc
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
{
|
||||||
|
"comments": false
|
||||||
|
}
|
||||||
3
packages/babel-cli/test/fixtures/babel/--config-file babelrc nocomment/options.json
vendored
Normal file
3
packages/babel-cli/test/fixtures/babel/--config-file babelrc nocomment/options.json
vendored
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
{
|
||||||
|
"args": ["--config-file", "../.othername_babelrc"]
|
||||||
|
}
|
||||||
7
packages/babel-cli/test/fixtures/babel/--config-file babelrc nocomment/stdin.txt
vendored
Normal file
7
packages/babel-cli/test/fixtures/babel/--config-file babelrc nocomment/stdin.txt
vendored
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
/*
|
||||||
|
Test comment
|
||||||
|
*/
|
||||||
|
|
||||||
|
arr.map(x => x * MULTIPLIER);
|
||||||
|
|
||||||
|
// END OF FILE
|
||||||
5
packages/babel-cli/test/fixtures/babel/--config-file babelrc nocomment/stdout.txt
vendored
Normal file
5
packages/babel-cli/test/fixtures/babel/--config-file babelrc nocomment/stdout.txt
vendored
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
"use strict";
|
||||||
|
|
||||||
|
arr.map(function (x) {
|
||||||
|
return x * MULTIPLIER;
|
||||||
|
});
|
||||||
12
yarn.lock
12
yarn.lock
@ -5367,6 +5367,18 @@ regenerator-runtime@^0.10.0:
|
|||||||
version "0.10.5"
|
version "0.10.5"
|
||||||
resolved "https://registry.yarnpkg.com/regenerator-runtime/-/regenerator-runtime-0.10.5.tgz#336c3efc1220adcedda2c9fab67b5a7955a33658"
|
resolved "https://registry.yarnpkg.com/regenerator-runtime/-/regenerator-runtime-0.10.5.tgz#336c3efc1220adcedda2c9fab67b5a7955a33658"
|
||||||
|
|
||||||
|
regenerator-runtime@^0.11.0:
|
||||||
|
version "0.11.0"
|
||||||
|
resolved "https://registry.yarnpkg.com/regenerator-runtime/-/regenerator-runtime-0.11.0.tgz#7e54fe5b5ccd5d6624ea6255c3473be090b802e1"
|
||||||
|
|
||||||
|
regenerator-transform@0.10.0:
|
||||||
|
version "0.10.0"
|
||||||
|
resolved "https://registry.yarnpkg.com/regenerator-transform/-/regenerator-transform-0.10.0.tgz#f9ab3eac9cc2de38431d996a6a8abf1c50f2e459"
|
||||||
|
dependencies:
|
||||||
|
babel-runtime "^6.18.0"
|
||||||
|
babel-types "^6.19.0"
|
||||||
|
private "^0.1.6"
|
||||||
|
|
||||||
regenerator-transform@0.9.11:
|
regenerator-transform@0.9.11:
|
||||||
version "0.9.11"
|
version "0.9.11"
|
||||||
resolved "https://registry.yarnpkg.com/regenerator-transform/-/regenerator-transform-0.9.11.tgz#3a7d067520cb7b7176769eb5ff868691befe1283"
|
resolved "https://registry.yarnpkg.com/regenerator-transform/-/regenerator-transform-0.9.11.tgz#3a7d067520cb7b7176769eb5ff868691befe1283"
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user