add --config-file option to CLI to pass in .babelrc location (#6133)

This commit is contained in:
Bryan Wain
2017-08-22 12:58:24 -05:00
committed by Justin Ridgewell
parent 7e726a81e6
commit 63baaa7148
6 changed files with 36 additions and 0 deletions

View File

@@ -48,6 +48,7 @@ commander.option(
"comma-separated list of plugin names",
collect,
);
commander.option("--config-file [path]", "Path a to .babelrc file to use");
// Basic file input configuration.
commander.option("--source-type [script|module]", "");
@@ -200,6 +201,10 @@ if (errors.length) {
//
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 opts.version;
@@ -210,6 +215,7 @@ delete opts.outFile;
delete opts.outDir;
delete opts.copyFiles;
delete opts.quiet;
delete opts.configFile;
// 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.

View File

@@ -0,0 +1,3 @@
{
"comments": false
}

View File

@@ -0,0 +1,3 @@
{
"args": ["--config-file", "../.othername_babelrc"]
}

View File

@@ -0,0 +1,7 @@
/*
Test comment
*/
arr.map(x => x * MULTIPLIER);
// END OF FILE

View File

@@ -0,0 +1,5 @@
"use strict";
arr.map(function (x) {
return x * MULTIPLIER;
});