Skip to content

Commit

Permalink
Propagates the extensions overrides provided by CLI during files walk (
Browse files Browse the repository at this point in the history
…#8668)

* Propagates the extensions overrides provided by CLI during files walk

* Adds tests for issue #7620, PR #8668
  • Loading branch information
katrotz authored and loganfsmyth committed Nov 30, 2018
1 parent 4e28459 commit 2bf8dde
Show file tree
Hide file tree
Showing 7 changed files with 24 additions and 2 deletions.
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;
});
Empty file.

0 comments on commit 2bf8dde

Please sign in to comment.