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

Prevent ignored files in out dir #10831

Merged
merged 5 commits into from Dec 18, 2019
Merged
Show file tree
Hide file tree
Changes from 2 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
12 changes: 10 additions & 2 deletions packages/babel-cli/src/babel/dir.js
Expand Up @@ -84,8 +84,16 @@ export default async function({

async function handleFile(src: string, base: string): Promise<boolean> {
const written = await write(src, base);

if (!written && cliOptions.copyFiles) {
const relative = path.relative(base, src);
const isCompilableExtension = util.isCompilableExtension(
relative,
cliOptions.extensions,
);
if (
!written &&
((!isCompilableExtension && cliOptions.copyFiles) ||
cliOptions.includeIgnore)
) {
const filename = path.relative(base, src);
const dest = getDest(filename, base);
outputFileSync(dest, fs.readFileSync(src));
Expand Down
6 changes: 6 additions & 0 deletions packages/babel-cli/src/babel/options.js
Expand Up @@ -161,6 +161,11 @@ commander.option(
"Delete the out directory before compilation.",
);

commander.option(
"--include-ignore",
"Include ignored files when compiling and copy to destination",
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need to rephrase this help text?

);

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 @@ -304,6 +309,7 @@ export default function parseArgv(args: Array<string>): CmdOptions | null {
quiet: opts.quiet,
deleteDirOnStart: opts.deleteDirOnStart,
sourceMapTarget: opts.sourceMapTarget,
includeIgnore: opts.includeIgnore,
},
};
}
Expand Down

This file was deleted.

@@ -0,0 +1,12 @@
{
"args": [
"src",
"--out-dir",
"lib",
"--copy-files",
"--ignore",
"src/foo/*",
"--include-ignore",
"--verbose"
]
}
@@ -0,0 +1,3 @@
"use strict";

index;
@@ -0,0 +1,2 @@
src/index.js -> lib/index.js
Successfully compiled 1 file with Babel.

This file was deleted.