Skip to content

Commit

Permalink
fix: Remove legacy spawnSync feature detection (#87)
Browse files Browse the repository at this point in the history
BREAKING CHANGE: no longer feature detect spawnSync, present since Node 0.11.
  • Loading branch information
demurgos authored and Benjamin E. Coe committed May 10, 2019
1 parent 4103f72 commit 78777aa
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 16 deletions.
20 changes: 5 additions & 15 deletions index.js
Expand Up @@ -41,11 +41,7 @@ const pathRe = isWindows ? /^PATH=/i : /^PATH=/
const colon = isWindows ? ';' : ':'

function wrap (argv, env, workingDir) {
// spawn_sync available since Node v0.11
let spawnSyncBinding, spawnSync
try {
spawnSyncBinding = process.binding('spawn_sync')
} catch (e) {}
const spawnSyncBinding = process.binding('spawn_sync')

// if we're passed in the working dir, then it means that setup
// was already done, so no need.
Expand All @@ -54,23 +50,17 @@ function wrap (argv, env, workingDir) {
workingDir = setup(argv, env)
}
const spawn = ChildProcess.prototype.spawn
if (spawnSyncBinding) {
spawnSync = spawnSyncBinding.spawn
}
const spawnSync = spawnSyncBinding.spawn

function unwrap () {
function unwrap() {
if (doSetup && !doDebug) {
rimraf.sync(workingDir)
}
ChildProcess.prototype.spawn = spawn
if (spawnSyncBinding) {
spawnSyncBinding.spawn = spawnSync
}
spawnSyncBinding.spawn = spawnSync
}

if (spawnSyncBinding) {
spawnSyncBinding.spawn = wrappedSpawnFunction(spawnSync, workingDir)
}
spawnSyncBinding.spawn = wrappedSpawnFunction(spawnSync, workingDir)
ChildProcess.prototype.spawn = wrappedSpawnFunction(spawn, workingDir)

return unwrap
Expand Down
1 change: 0 additions & 1 deletion shim.js
Expand Up @@ -134,7 +134,6 @@
const pexec = process.execArgv
if (JSON.stringify(pexec) !== JSON.stringify(needExecArgv)) {
debug('need execArgv for this', pexec, '=>', needExecArgv)
const spawn = require('child_process').spawn
const sargs = pexec.concat(needExecArgv).concat(process.argv.slice(1))
foregroundChild(node, sargs)
return
Expand Down

0 comments on commit 78777aa

Please sign in to comment.