diff --git a/packages/supertape/.putout.json b/packages/supertape/.putout.json index d940109..c0bbf78 100644 --- a/packages/supertape/.putout.json +++ b/packages/supertape/.putout.json @@ -11,7 +11,5 @@ "convert-esm-to-commonjs": "on" } }, - "ignore": [ - "test" - ] + "ignore": ["test"] } diff --git a/packages/supertape/lib/cli.js b/packages/supertape/lib/cli.js index 46b4f85..9428330 100644 --- a/packages/supertape/lib/cli.js +++ b/packages/supertape/lib/cli.js @@ -5,7 +5,7 @@ const {once} = require('events'); const {pathToFileURL} = require('url'); const yargsParser = require('yargs-parser'); -const glob = require('glob'); +const {glob} = require('glob'); const fullstore = require('fullstore'); const tryToCatch = require('try-to-catch'); const keypress = require('@putout/cli-keypress'); @@ -25,7 +25,6 @@ const {isArray} = Array; const maybeFirst = (a) => isArray(a) ? a.pop() : a; const maybeArray = (a) => isArray(a) ? a : [a]; -const isExclude = (a) => !a.includes('node_modules'); const removeDuplicates = (a) => Array.from(new Set(a)); const filesCount = fullstore(0); @@ -147,13 +146,11 @@ async function cli({argv, cwd, stdout, isStop}) { const allFiles = []; - for (const arg of args._) { - const files = glob - .sync(arg) - .filter(isExclude); - - allFiles.push(...files); - } + const globFiles = await glob(args._, { + ignore: 'node_modules/**', + }); + + allFiles.push(...globFiles); const { format, diff --git a/packages/supertape/lib/cli.spec.js b/packages/supertape/lib/cli.spec.js index 75b99b7..663422a 100644 --- a/packages/supertape/lib/cli.spec.js +++ b/packages/supertape/lib/cli.spec.js @@ -63,10 +63,10 @@ test('supertape: cli: -v', async (t) => { test('supertape: bin: cli: glob', async (t) => { const argv = ['hello']; - const sync = stub().returns([]); + const glob = stub().resolves([]); mockRequire('glob', { - sync, + glob, }); await runCli({ @@ -75,7 +75,7 @@ test('supertape: bin: cli: glob', async (t) => { stopAll(); - t.calledWith(sync, ['hello']); + t.calledWith(glob, ['hello']); t.end(); }); @@ -85,10 +85,10 @@ test('supertape: bin: cli: glob: a couple', async (t) => { 'world', ]; - const sync = stub().returns([]); + const glob = stub().resolves([]); mockRequire('glob', { - sync, + glob, }); await runCli({ @@ -97,9 +97,13 @@ test('supertape: bin: cli: glob: a couple', async (t) => { stopAll(); - const [[first], [second]] = sync.args; + const [result] = glob.args; + const expected = [ + ['hello', 'world'], { + ignore: 'node_modules/**', + }]; - t.deepEqual([first, second], ['hello', 'world'], 'should call glob.sync on every iteration'); + t.deepEqual(result, expected, 'should call glob on every iteration'); t.end(); }); @@ -305,6 +309,7 @@ test('supertape: cli: exit: skiped', async (t) => { mockRequire('..', test); const emit = emitter.emit.bind(emitter); + await Promise.all([ runCli({ argv, diff --git a/packages/supertape/lib/formatter/harness.js b/packages/supertape/lib/formatter/harness.js index d628884..6c07a14 100644 --- a/packages/supertape/lib/formatter/harness.js +++ b/packages/supertape/lib/formatter/harness.js @@ -6,6 +6,7 @@ const {assign} = Object; module.exports.createHarness = (reporter) => { const prepared = prepare(reporter); + let is = false; const stream = new Transform({ readableObjectMode: true, writableObjectMode: true, @@ -14,11 +15,15 @@ module.exports.createHarness = (reporter) => { const {type, ...data} = chunk; const result = run(prepared, type, data); - if (result) + if (!is && result) { this.push(result); + } - if (type === 'end') + if (type === 'end') { + is = true; + this.push(null); + } callback(); }, diff --git a/packages/supertape/package.json b/packages/supertape/package.json index 084cd68..243db6d 100644 --- a/packages/supertape/package.json +++ b/packages/supertape/package.json @@ -52,7 +52,7 @@ "cli-progress": "^3.8.2", "deep-equal": "^2.0.3", "fullstore": "^3.0.0", - "glob": "^8.0.3", + "glob": "^10.3.3", "jest-diff": "^29.0.1", "once": "^1.4.0", "resolve": "^1.17.0",