Skip to content

Commit

Permalink
Add test for special npm handling
Browse files Browse the repository at this point in the history
  • Loading branch information
Benjamin Coe authored and addaleax committed Apr 3, 2016
1 parent f5a93b5 commit 8da4196
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 0 deletions.
36 changes: 36 additions & 0 deletions test/basic.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ var winNoSig = isWindows && 'no signals get through cmd'
var onExit = require('signal-exit')
var cp = require('child_process')
var fixture = require.resolve('./fixtures/script.js')
var npmFixture = require.resolve('./fixtures/npm')
var fs = require('fs')
var path = require('path')

Expand Down Expand Up @@ -293,6 +294,41 @@ t.test('exec shebang', { skip: winNoShebang }, function (t) {
})
})

// see: https://github.com/bcoe/nyc/issues/190
t.test('Node 5.8.x + npm 3.7.x - spawn', function (t) {
var npmdir = path.dirname(npmFixture)
process.env.PATH = npmdir + (isWindows ? ';' : ':') + (process.env.PATH || '')
var child = cp.spawn('npm', ['xyz'])

var out = ''
child.stdout.on('data', function (c) {
out += c
})
child.on('close', function (code, signal) {
t.equal(code, 0)
t.equal(signal, null)
t.true(~out.indexOf('xyz'))
t.end()
})
})

t.test('Node 5.8.x + npm 3.7.x - shell', function (t) {
var npmdir = path.dirname(npmFixture)
process.env.PATH = npmdir + (isWindows ? ';' : ':') + (process.env.PATH || '')
var child = cp.exec('npm xyz')

var out = ''
child.stdout.on('data', function (c) {
out += c
})
child.on('close', function (code, signal) {
t.equal(code, 0)
t.equal(signal, null)
t.true(~out.indexOf('xyz'))
t.end()
})
})

t.test('--harmony', function (t) {
var node = process.execPath
var child = cp.spawn(node, ['--harmony', fixture, 'xyz'])
Expand Down
4 changes: 4 additions & 0 deletions test/fixtures/npm
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/sh
// 2>/dev/null; exec "`dirname "$0"`/node" "$0" "$@"
console.log('%j', process.execArgv)
console.log('%j', process.argv.slice(2))

0 comments on commit 8da4196

Please sign in to comment.