Skip to content

Commit

Permalink
Bugfix: for [nyc issue 784](istanbuljs/nyc#784). Tested on windows 10…
Browse files Browse the repository at this point in the history
… in powershell and cmd.
  • Loading branch information
MarcusPope committed Jun 28, 2019
1 parent 1fae96f commit ed9558b
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lib/mungers/cmd.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ function mungeCmd(workingDir, options) {

let npmPath = whichOrUndefined('npm') || 'npm'
npmPath = path.dirname(npmPath) + '\\node_modules\\npm\\bin\\npm-cli.js'
replace = m[1] + workingDir + '/node.cmd' +
replace = m[1] + '"' + workingDir + '/node.cmd"' +
' "' + npmPath + '"' +
m[3] + m[4]
options.args[cmdi + 1] = command.replace(npmre, replace)
Expand Down
27 changes: 26 additions & 1 deletion test/basic.js
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ t.test('spawn node', function (t) {
})

t.test('exec execPath', function (t) {
t.plan(4)
t.plan(5)

t.test('basic', function (t) {
var opt = IS_WINDOWS ? null : { shell: '/bin/bash' }
Expand Down Expand Up @@ -228,6 +228,31 @@ t.test('exec execPath', function (t) {
})
})

t.test('spaces in path on windows', { skip: !IS_WINDOWS }, function(t) {

//create temp folder with spaces in path
var dir = path.join(__dirname, 'fixtures', 'space path');
fs.mkdirSync(dir);
var fp = path.join(__dirname, 'fixtures', 'space path', 'node.exe');
fs.writeFileSync(fp, fs.readFileSync(process.execPath));
fs.chmodSync(fp, '0775');

var child = cp.exec(JSON.stringify(fp) + ' ' + fixture + ' xyz', null);
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.equal(out, expect)
fs.unlinkSync(fp);
fs.rmdirSync(dir);
t.end();
});
});

t.test('SIGINT', { skip: winNoSig }, function (t) {
var child = cp.exec(process.execPath + ' ' + fixture + ' xyz', { shell: '/bin/bash' })

Expand Down

0 comments on commit ed9558b

Please sign in to comment.