From 6a1ce4389e8b601249c3c81b31cd60eea3e0f74a Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Mon, 15 Aug 2022 21:57:18 -0700 Subject: [PATCH] [New] `bin/tape`: include the exact arg when there are no glob results; use require on `--require` files --- bin/tape | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/bin/tape b/bin/tape index f774228f..2783f5da 100755 --- a/bin/tape +++ b/bin/tape @@ -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) {