Skip to content

Commit

Permalink
[Refactor] bin/tape: separate "preparing of files list" from "requi…
Browse files Browse the repository at this point in the history
…re files list"
  • Loading branch information
ljharb committed Jun 4, 2021
1 parent e211546 commit 021fa6d
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions bin/tape
Expand Up @@ -41,7 +41,7 @@ if (typeof opts.ignore === 'string') {
var matcher = ignore.createMatcher(ignoreStr);
}

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

files.filter(function (file) { return !matcher || !matcher.shouldIgnore(file); }).forEach(function (file) {
require(resolvePath(cwd, file));
});
return result.concat(files);
}, []).filter(function (file) {
return !matcher || !matcher.shouldIgnore(file);
}).map(function (file) {
return resolvePath(cwd, file);
});

files.forEach(function (x) { require(x); });

// vim: ft=javascript

0 comments on commit 021fa6d

Please sign in to comment.