diff options
Diffstat (limited to 'deps/npm/test/lib/commands/test.js')
-rw-r--r-- | deps/npm/test/lib/commands/test.js | 16 |
1 files changed, 5 insertions, 11 deletions
diff --git a/deps/npm/test/lib/commands/test.js b/deps/npm/test/lib/commands/test.js index c6d3f530bb6..a6a6f723afe 100644 --- a/deps/npm/test/lib/commands/test.js +++ b/deps/npm/test/lib/commands/test.js @@ -1,5 +1,3 @@ -const fs = require('fs') -const path = require('path') const t = require('tap') const tspawk = require('../../fixtures/tspawk') const { load: loadMockNpm } = require('../../fixtures/mock-npm') @@ -26,15 +24,11 @@ t.test('should run test script from package.json', async t => { loglevel: 'silent', }, }) - const [scriptShell] = makeSpawnArgs({ path: npm.prefix, cmd: 'node ./test-test.js' }) - const script = spawk.spawn(scriptShell, (args) => { - const lastArg = args[args.length - 1] - const rightExtension = lastArg.endsWith('.cmd') || lastArg.endsWith('.sh') - const rightFilename = path.basename(lastArg).startsWith('test') - const rightContents = fs.readFileSync(lastArg, { encoding: 'utf8' }) - .trim().endsWith('foo') - return rightExtension && rightFilename && rightContents - }) + const [scriptShell, scriptArgs] = makeSpawnArgs({ path: npm.prefix, cmd: 'node ./test-test.js' }) + let scriptContent = scriptArgs.pop() + scriptContent += ' foo' + scriptArgs.push(scriptContent) + const script = spawk.spawn(scriptShell, scriptArgs) await npm.exec('test', ['foo']) t.ok(script.called, 'script ran') }) |