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

Propagates the extensions overrides provided by CLI during files walk #8668

Merged
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
6 changes: 5 additions & 1 deletion packages/babel-cli/src/babel/file.js
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,11 @@ export default async function({ cliOptions, babelOptions }) {
const dirname = filename;

util
.readdirForCompilable(filename, cliOptions.includeDotfiles)
.readdirForCompilable(
filename,
cliOptions.includeDotfiles,
cliOptions.extensions,
)
.forEach(function(filename) {
_filenames.push(path.join(dirname, filename));
});
Expand Down
5 changes: 4 additions & 1 deletion packages/babel-cli/src/babel/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,11 @@ export function readdir(
export function readdirForCompilable(
dirname: string,
includeDotfiles: boolean,
altExts?: Array<string>,
) {
return readdir(dirname, includeDotfiles, isCompilableExtension);
return readdir(dirname, includeDotfiles, function(filename) {
return isCompilableExtension(filename, altExts);
});
}

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
(() => 42)
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
arr.map(x => x * MULTIPLIER);
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"args": ["src", "--out-file", "test.js", "--extensions", ".es"]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
"use strict";

(function () {
return 42;
});
"use strict";

arr.map(function (x) {
return x * MULTIPLIER;
});