--copy-ignored flag added to CLI (#10887)
* prevent ignored files in out dir * added includeIgnore cli option * Help text change * Update packages/babel-cli/src/babel/options.js Copy review. Co-Authored-By: Brian Ng <bng412@gmail.com> * review comments * throw error if copyIgnored is used without ignore flag * check for ignored files * duplicate pathToPattern fn in babel/cli * change implementation * removed ignore option from cliOption * added test case with ignore in config * added test case with ignore in config * review Co-authored-by: Brian Ng <bng412@gmail.com>
This commit is contained in:
committed by
Nicolò Ribaudo
parent
3af02f63de
commit
8415065d99
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"ignore": ["src/foo"]
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
{
|
||||
"args": [
|
||||
"src",
|
||||
"--out-dir",
|
||||
"lib",
|
||||
"--copy-files",
|
||||
"--include-dotfiles",
|
||||
"--verbose"
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
"use strict";
|
||||
|
||||
index;
|
||||
@@ -0,0 +1,2 @@
|
||||
src/index.js -> lib/index.js
|
||||
Successfully compiled 1 file with Babel.
|
||||
@@ -0,0 +1 @@
|
||||
src/foo
|
||||
@@ -0,0 +1,10 @@
|
||||
{
|
||||
"args": [
|
||||
"src",
|
||||
"--out-dir",
|
||||
"lib",
|
||||
"--copy-files",
|
||||
"--copy-ignored",
|
||||
"--verbose"
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
bar;
|
||||
@@ -0,0 +1,3 @@
|
||||
"use strict";
|
||||
|
||||
index;
|
||||
@@ -0,0 +1,2 @@
|
||||
src/index.js -> lib/index.js
|
||||
Successfully compiled 1 file with Babel.
|
||||
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"ignore": ["src/foo"]
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
bar;
|
||||
@@ -0,0 +1 @@
|
||||
index;
|
||||
@@ -0,0 +1,10 @@
|
||||
{
|
||||
"args": [
|
||||
"src",
|
||||
"--out-dir",
|
||||
"lib",
|
||||
"--copy-files",
|
||||
"--copy-ignored",
|
||||
"--verbose"
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
bar;
|
||||
@@ -0,0 +1,3 @@
|
||||
"use strict";
|
||||
|
||||
index;
|
||||
@@ -0,0 +1,2 @@
|
||||
src/index.js -> lib/index.js
|
||||
Successfully compiled 1 file with Babel.
|
||||
1
packages/babel-cli/test/fixtures/babel/--copy-files with ignore in babelignore/.babelignore
vendored
Normal file
1
packages/babel-cli/test/fixtures/babel/--copy-files with ignore in babelignore/.babelignore
vendored
Normal file
@@ -0,0 +1 @@
|
||||
src/foo
|
||||
@@ -0,0 +1 @@
|
||||
bar;
|
||||
@@ -0,0 +1 @@
|
||||
index;
|
||||
9
packages/babel-cli/test/fixtures/babel/--copy-files with ignore in babelignore/options.json
vendored
Normal file
9
packages/babel-cli/test/fixtures/babel/--copy-files with ignore in babelignore/options.json
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"args": [
|
||||
"src",
|
||||
"--out-dir",
|
||||
"lib",
|
||||
"--copy-files",
|
||||
"--verbose"
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
"use strict";
|
||||
|
||||
index;
|
||||
2
packages/babel-cli/test/fixtures/babel/--copy-files with ignore in babelignore/stdout.txt
vendored
Normal file
2
packages/babel-cli/test/fixtures/babel/--copy-files with ignore in babelignore/stdout.txt
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
src/index.js -> lib/index.js
|
||||
Successfully compiled 1 file with Babel.
|
||||
3
packages/babel-cli/test/fixtures/babel/--copy-files with ignore in babelrc/.babelrc
vendored
Normal file
3
packages/babel-cli/test/fixtures/babel/--copy-files with ignore in babelrc/.babelrc
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"ignore": ["src/foo"]
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
bar;
|
||||
@@ -0,0 +1 @@
|
||||
index;
|
||||
9
packages/babel-cli/test/fixtures/babel/--copy-files with ignore in babelrc/options.json
vendored
Normal file
9
packages/babel-cli/test/fixtures/babel/--copy-files with ignore in babelrc/options.json
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"args": [
|
||||
"src",
|
||||
"--out-dir",
|
||||
"lib",
|
||||
"--copy-files",
|
||||
"--verbose"
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
"use strict";
|
||||
|
||||
index;
|
||||
2
packages/babel-cli/test/fixtures/babel/--copy-files with ignore in babelrc/stdout.txt
vendored
Normal file
2
packages/babel-cli/test/fixtures/babel/--copy-files with ignore in babelrc/stdout.txt
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
src/index.js -> lib/index.js
|
||||
Successfully compiled 1 file with Babel.
|
||||
@@ -0,0 +1 @@
|
||||
bar;
|
||||
@@ -0,0 +1 @@
|
||||
index;
|
||||
12
packages/babel-cli/test/fixtures/babel/--copy-files with ignore with copyIgnored/options.json
vendored
Normal file
12
packages/babel-cli/test/fixtures/babel/--copy-files with ignore with copyIgnored/options.json
vendored
Normal file
@@ -0,0 +1,12 @@
|
||||
{
|
||||
"args": [
|
||||
"src",
|
||||
"--out-dir",
|
||||
"lib",
|
||||
"--copy-files",
|
||||
"--ignore",
|
||||
"src/foo",
|
||||
"--copy-ignored",
|
||||
"--verbose"
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
bar;
|
||||
@@ -0,0 +1,3 @@
|
||||
"use strict";
|
||||
|
||||
index;
|
||||
2
packages/babel-cli/test/fixtures/babel/--copy-files with ignore with copyIgnored/stdout.txt
vendored
Normal file
2
packages/babel-cli/test/fixtures/babel/--copy-files with ignore with copyIgnored/stdout.txt
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
src/index.js -> lib/index.js
|
||||
Successfully compiled 1 file with Babel.
|
||||
@@ -0,0 +1 @@
|
||||
bar;
|
||||
@@ -0,0 +1 @@
|
||||
index;
|
||||
12
packages/babel-cli/test/fixtures/babel/--copy-files with only copy copyIgnored/options.json
vendored
Normal file
12
packages/babel-cli/test/fixtures/babel/--copy-files with only copy copyIgnored/options.json
vendored
Normal file
@@ -0,0 +1,12 @@
|
||||
{
|
||||
"args": [
|
||||
"src",
|
||||
"--out-dir",
|
||||
"lib",
|
||||
"--copy-files",
|
||||
"--only",
|
||||
"src/foo/*",
|
||||
"--copy-ignored",
|
||||
"--verbose"
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
"use strict";
|
||||
|
||||
bar;
|
||||
@@ -0,0 +1 @@
|
||||
index;
|
||||
2
packages/babel-cli/test/fixtures/babel/--copy-files with only copy copyIgnored/stdout.txt
vendored
Normal file
2
packages/babel-cli/test/fixtures/babel/--copy-files with only copy copyIgnored/stdout.txt
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
src/foo/bar.js -> lib/foo/bar.js
|
||||
Successfully compiled 1 file with Babel.
|
||||
@@ -97,6 +97,7 @@ const assertTest = function(stdout, stderr, opts, cwd) {
|
||||
if (
|
||||
// saveInFiles always creates an empty .babelrc, so lets exclude for now
|
||||
filename !== ".babelrc" &&
|
||||
filename !== ".babelignore" &&
|
||||
!Object.prototype.hasOwnProperty.call(opts.inFiles, filename)
|
||||
) {
|
||||
const expected = opts.outFiles[filename];
|
||||
@@ -239,9 +240,15 @@ fs.readdirSync(fixtureLoc).forEach(function(binName) {
|
||||
opts.inFiles = readDir(path.join(testLoc, "in-files"), fileFilter);
|
||||
|
||||
const babelrcLoc = path.join(testLoc, ".babelrc");
|
||||
const babelIgnoreLoc = path.join(testLoc, ".babelignore");
|
||||
if (fs.existsSync(babelrcLoc)) {
|
||||
// copy .babelrc file to tmp directory
|
||||
opts.inFiles[".babelrc"] = helper.readFile(babelrcLoc);
|
||||
opts.inFiles[".babelignore"] = helper.readFile(babelIgnoreLoc);
|
||||
}
|
||||
if (fs.existsSync(babelIgnoreLoc)) {
|
||||
// copy .babelignore file to tmp directory
|
||||
opts.inFiles[".babelignore"] = helper.readFile(babelIgnoreLoc);
|
||||
}
|
||||
|
||||
it(testName, buildTest(binName, testName, opts), 20000);
|
||||
|
||||
Reference in New Issue
Block a user