Skip to content

Commit

Permalink
[New] bin/tape: include the exact arg when there are no glob result…
Browse files Browse the repository at this point in the history
…s; use require on `--require` files
  • Loading branch information
ljharb committed Aug 16, 2022
1 parent fbdbfc9 commit 6a1ce43
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions bin/tape
Original file line number Diff line number Diff line change
Expand Up @@ -48,14 +48,17 @@ if (typeof opts.ignore === 'string') {
var glob = require('glob');

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 (glob.hasMagic(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.');
}
if (!Array.isArray(files)) {
throw new TypeError('unknown error: glob.sync did not return an array or throw. Please report this.');
}

return result.concat(files);
return result.concat(files);
}
return result.concat(arg);
}, []).filter(function (file) {
return !matcher || !matcher.shouldIgnore(file);
}).forEach(function (file) {
Expand Down

0 comments on commit 6a1ce43

Please sign in to comment.