Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 1 commit into from Jan 30, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
13 changes: 7 additions & 6 deletions packages/babel-cli/src/babel/options.js
Expand Up @@ -140,6 +140,7 @@ commander.option(
"--relative",
"Compile into an output directory relative to input directory or file. Requires --out-dir [out]",
);

commander.option(
"-D, --copy-files",
"When compiling a directory copy over non-compilable files.",
Expand All @@ -148,6 +149,11 @@ commander.option(
"--include-dotfiles",
"Include dotfiles when compiling and copying non-compilable files.",
);
commander.option(
"--no-copy-ignored",
"Exclude ignored files when copying non-compilable files.",
);

commander.option(
"--verbose",
"Log everything. This option conflicts with --quiet",
Expand All @@ -165,11 +171,6 @@ commander.option(
"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.usage("[options] <files ...>");
// register an empty action handler so that commander.js can throw on
Expand Down Expand Up @@ -315,12 +316,12 @@ export default function parseArgv(args: Array<string>): CmdOptions | null {
outDir: opts.outDir,
relative: opts.relative,
copyFiles: opts.copyFiles,
copyIgnored: opts.copyFiles && opts.copyIgnored,
includeDotfiles: opts.includeDotfiles,
verbose: opts.verbose,
quiet: opts.quiet,
deleteDirOnStart: opts.deleteDirOnStart,
sourceMapTarget: opts.sourceMapTarget,
copyIgnored: opts.copyIgnored,
},
};
}
Expand Down
@@ -0,0 +1 @@
a;
@@ -0,0 +1 @@
a;
@@ -0,0 +1 @@
"use strict";
Expand Up @@ -4,7 +4,7 @@
"--out-dir",
"lib",
"--copy-files",
"--copy-ignored",
"--no-copy-ignored",
"--verbose"
]
}
Expand Up @@ -4,7 +4,7 @@
"--out-dir",
"lib",
"--copy-files",
"--copy-ignored",
"--no-copy-ignored",
"--verbose"
]
}
Expand Up @@ -6,7 +6,7 @@
"--copy-files",
"--ignore",
"src/foo",
"--copy-ignored",
"--no-copy-ignored",
"--verbose"
]
}
Expand Up @@ -6,7 +6,7 @@
"--copy-files",
"--only",
"src/foo/*",
"--copy-ignored",
"--no-copy-ignored",
"--verbose"
]
}
@@ -0,0 +1 @@
bar;
@@ -0,0 +1 @@
bar;
@@ -0,0 +1 @@
index;
27 changes: 14 additions & 13 deletions packages/babel-cli/test/index.js
Expand Up @@ -94,20 +94,21 @@ const assertTest = function(stdout, stderr, opts, cwd) {
const actualFiles = readDir(tmpLoc, fileFilter);

Object.keys(actualFiles).forEach(function(filename) {
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];
const actual = actualFiles[filename];

expect(expected).not.toBeUndefined();

if (expected) {
expect(actual).toBe(expected);
try {
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];
const actual = actualFiles[filename];

expect(actual).toBe(expected ?? "");
}
} catch (e) {
e.message += "\n at " + filename;
throw e;
}
});

Expand Down