diff options
Diffstat (limited to 'test/lib/commands/start.js')
-rw-r--r-- | test/lib/commands/start.js | 17 |
1 files changed, 6 insertions, 11 deletions
diff --git a/test/lib/commands/start.js b/test/lib/commands/start.js index 79c2133bc..3caaa478f 100644 --- a/test/lib/commands/start.js +++ b/test/lib/commands/start.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,12 @@ t.test('should run start script from package.json', async t => { loglevel: 'silent', }, }) - const [scriptShell] = makeSpawnArgs({ path: npm.prefix, cmd: 'node ./test-start.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('start') - const rightContents = fs.readFileSync(lastArg, { encoding: 'utf8' }) - .trim().endsWith('foo') - return rightExtension && rightFilename && rightContents - }) + const [scriptShell, scriptArgs] = makeSpawnArgs({ path: npm.prefix, cmd: 'node ./test-start.js' }) + // we're calling the script with 'foo' as an argument, so add that to the script + let scriptContent = scriptArgs.pop() + scriptContent += ' foo' + scriptArgs.push(scriptContent) + const script = spawk.spawn(scriptShell, scriptArgs) await npm.exec('start', ['foo']) t.ok(script.called, 'script ran') }) |