Skip to content

Commit 021fa6d

Browse files
committed
[Refactor] bin/tape: separate "preparing of files list" from "require files list"
1 parent e211546 commit 021fa6d

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

bin/tape

+8-4
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ if (typeof opts.ignore === 'string') {
4141
var matcher = ignore.createMatcher(ignoreStr);
4242
}
4343

44-
opts._.forEach(function (arg) {
44+
var files = opts._.reduce(function (result, arg) {
4545
// If glob does not match, `files` will be an empty array.
4646
// Note: `glob.sync` may throw an error and crash the node process.
4747
var files = glob.sync(arg);
@@ -50,9 +50,13 @@ opts._.forEach(function (arg) {
5050
throw new TypeError('unknown error: glob.sync did not return an array or throw. Please report this.');
5151
}
5252

53-
files.filter(function (file) { return !matcher || !matcher.shouldIgnore(file); }).forEach(function (file) {
54-
require(resolvePath(cwd, file));
55-
});
53+
return result.concat(files);
54+
}, []).filter(function (file) {
55+
return !matcher || !matcher.shouldIgnore(file);
56+
}).map(function (file) {
57+
return resolvePath(cwd, file);
5658
});
5759

60+
files.forEach(function (x) { require(x); });
61+
5862
// vim: ft=javascript

0 commit comments

Comments
 (0)