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

* Propagates the extensions overrides provided by CLI during files walk

* Adds tests for issue #7620, PR #8668
This commit is contained in:
Veaceslav Cotruta 2018-11-30 03:57:27 +01:00 committed by Logan Smyth
parent 4e28459a2f
commit 2bf8dde782
7 changed files with 24 additions and 2 deletions

View File

@ -137,7 +137,11 @@ export default async function({ cliOptions, babelOptions }) {
const dirname = filename; const dirname = filename;
util util
.readdirForCompilable(filename, cliOptions.includeDotfiles) .readdirForCompilable(
filename,
cliOptions.includeDotfiles,
cliOptions.extensions,
)
.forEach(function(filename) { .forEach(function(filename) {
_filenames.push(path.join(dirname, filename)); _filenames.push(path.join(dirname, filename));
}); });

View File

@ -29,8 +29,11 @@ export function readdir(
export function readdirForCompilable( export function readdirForCompilable(
dirname: string, dirname: string,
includeDotfiles: boolean, includeDotfiles: boolean,
altExts?: Array<string>,
) { ) {
return readdir(dirname, includeDotfiles, isCompilableExtension); return readdir(dirname, includeDotfiles, function(filename) {
return isCompilableExtension(filename, altExts);
});
} }
/** /**

View File

@ -0,0 +1 @@
(() => 42)

View File

@ -0,0 +1 @@
arr.map(x => x * MULTIPLIER);

View File

@ -0,0 +1,3 @@
{
"args": ["src", "--out-file", "test.js", "--extensions", ".es"]
}

View File

@ -0,0 +1,10 @@
"use strict";
(function () {
return 42;
});
"use strict";
arr.map(function (x) {
return x * MULTIPLIER;
});