Skip to content

Commit

Permalink
[Refactor] bin/tape: make it a bit more functional, for easier v5 b…
Browse files Browse the repository at this point in the history
…ackporting
  • Loading branch information
ljharb committed Aug 16, 2022
1 parent 6a3c200 commit fbdbfc9
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions bin/tape
Original file line number Diff line number Diff line change
Expand Up @@ -47,17 +47,19 @@ if (typeof opts.ignore === 'string') {

var glob = require('glob');

opts._.forEach(function (arg) {
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);

if (!Array.isArray(files)) {
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);
}).forEach(function (file) {
require(resolvePath(cwd, file));
});

// vim: ft=javascript

0 comments on commit fbdbfc9

Please sign in to comment.