Skip to content

Commit bf8aca0

Browse files
committed
fix spawn EINVAL error
fixes #68
1 parent f891aa5 commit bf8aca0

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

bin.js

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@ if (!buildFromSource()) {
1616
}
1717

1818
function build () {
19-
var args = [os.platform() === 'win32' ? 'node-gyp.cmd' : 'node-gyp', 'rebuild']
19+
var win32 = os.platform() === 'win32'
20+
var args = [win32 ? 'node-gyp.cmd' : 'node-gyp', 'rebuild']
2021

2122
try {
2223
var pkg = require('node-gyp/package.json')
@@ -27,7 +28,7 @@ function build () {
2728
]
2829
} catch (_) {}
2930

30-
proc.spawn(args[0], args.slice(1), { stdio: 'inherit' }).on('exit', function (code) {
31+
proc.spawn(args[0], args.slice(1), { stdio: 'inherit', shell: win32, windowsHide: true }).on('exit', function (code) {
3132
if (code || !process.argv[3]) process.exit(code)
3233
exec(process.argv[3]).on('exit', function (code) {
3334
process.exit(code)
@@ -45,15 +46,18 @@ function preinstall () {
4546

4647
function exec (cmd) {
4748
if (process.platform !== 'win32') {
48-
var shell = os.platform() === 'android' ? 'sh' : '/bin/sh'
49-
return proc.spawn(shell, ['-c', '--', cmd], {
49+
var shell = os.platform() === 'android' ? 'sh' : true
50+
return proc.spawn(cmd, [], {
51+
shell,
5052
stdio: 'inherit'
5153
})
5254
}
5355

54-
return proc.spawn(process.env.comspec || 'cmd.exe', ['/s', '/c', '"' + cmd + '"'], {
56+
return proc.spawn(cmd, [], {
5557
windowsVerbatimArguments: true,
56-
stdio: 'inherit'
58+
stdio: 'inherit',
59+
shell: true,
60+
windowsHide: true
5761
})
5862
}
5963

0 commit comments

Comments
 (0)