[@babel/cli] Copy ignored files by default (#11063)

This commit restores the pre-7.8.0 behavior of the --copy-files option, by making
--copy-ignored default to true when --copy-files is enabled.
This commit is contained in:
Nicolò Ribaudo 2020-01-30 13:01:04 +01:00 committed by GitHub
parent 1528d7d2d3
commit 92c6807ae8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
46 changed files with 30 additions and 22 deletions

View File

@ -140,6 +140,7 @@ commander.option(
"--relative", "--relative",
"Compile into an output directory relative to input directory or file. Requires --out-dir [out]", "Compile into an output directory relative to input directory or file. Requires --out-dir [out]",
); );
commander.option( commander.option(
"-D, --copy-files", "-D, --copy-files",
"When compiling a directory copy over non-compilable files.", "When compiling a directory copy over non-compilable files.",
@ -148,6 +149,11 @@ commander.option(
"--include-dotfiles", "--include-dotfiles",
"Include dotfiles when compiling and copying non-compilable files.", "Include dotfiles when compiling and copying non-compilable files.",
); );
commander.option(
"--no-copy-ignored",
"Exclude ignored files when copying non-compilable files.",
);
commander.option( commander.option(
"--verbose", "--verbose",
"Log everything. This option conflicts with --quiet", "Log everything. This option conflicts with --quiet",
@ -165,11 +171,6 @@ commander.option(
"Use a specific extension for the output files", "Use a specific extension for the output files",
); );
commander.option(
"--copy-ignored",
"Include ignored files when copying non-compilable files.",
);
commander.version(pkg.version + " (@babel/core " + version + ")"); commander.version(pkg.version + " (@babel/core " + version + ")");
commander.usage("[options] <files ...>"); commander.usage("[options] <files ...>");
// register an empty action handler so that commander.js can throw on // register an empty action handler so that commander.js can throw on
@ -315,12 +316,12 @@ export default function parseArgv(args: Array<string>): CmdOptions | null {
outDir: opts.outDir, outDir: opts.outDir,
relative: opts.relative, relative: opts.relative,
copyFiles: opts.copyFiles, copyFiles: opts.copyFiles,
copyIgnored: opts.copyFiles && opts.copyIgnored,
includeDotfiles: opts.includeDotfiles, includeDotfiles: opts.includeDotfiles,
verbose: opts.verbose, verbose: opts.verbose,
quiet: opts.quiet, quiet: opts.quiet,
deleteDirOnStart: opts.deleteDirOnStart, deleteDirOnStart: opts.deleteDirOnStart,
sourceMapTarget: opts.sourceMapTarget, sourceMapTarget: opts.sourceMapTarget,
copyIgnored: opts.copyIgnored,
}, },
}; };
} }

View File

@ -4,7 +4,7 @@
"--out-dir", "--out-dir",
"lib", "lib",
"--copy-files", "--copy-files",
"--copy-ignored", "--no-copy-ignored",
"--verbose" "--verbose"
] ]
} }

View File

@ -4,7 +4,7 @@
"--out-dir", "--out-dir",
"lib", "lib",
"--copy-files", "--copy-files",
"--copy-ignored", "--no-copy-ignored",
"--verbose" "--verbose"
] ]
} }

View File

@ -6,7 +6,7 @@
"--copy-files", "--copy-files",
"--ignore", "--ignore",
"src/foo", "src/foo",
"--copy-ignored", "--no-copy-ignored",
"--verbose" "--verbose"
] ]
} }

View File

@ -6,7 +6,7 @@
"--copy-files", "--copy-files",
"--only", "--only",
"src/foo/*", "src/foo/*",
"--copy-ignored", "--no-copy-ignored",
"--verbose" "--verbose"
] ]
} }

View File

@ -0,0 +1 @@
index;

View File

@ -94,20 +94,21 @@ const assertTest = function(stdout, stderr, opts, cwd) {
const actualFiles = readDir(tmpLoc, fileFilter); const actualFiles = readDir(tmpLoc, fileFilter);
Object.keys(actualFiles).forEach(function(filename) { Object.keys(actualFiles).forEach(function(filename) {
if ( try {
// saveInFiles always creates an empty .babelrc, so lets exclude for now if (
filename !== ".babelrc" && // saveInFiles always creates an empty .babelrc, so lets exclude for now
filename !== ".babelignore" && filename !== ".babelrc" &&
!Object.prototype.hasOwnProperty.call(opts.inFiles, filename) filename !== ".babelignore" &&
) { !Object.prototype.hasOwnProperty.call(opts.inFiles, filename)
const expected = opts.outFiles[filename]; ) {
const actual = actualFiles[filename]; const expected = opts.outFiles[filename];
const actual = actualFiles[filename];
expect(expected).not.toBeUndefined(); expect(actual).toBe(expected ?? "");
if (expected) {
expect(actual).toBe(expected);
} }
} catch (e) {
e.message += "\n at " + filename;
throw e;
} }
}); });