[Pkg-javascript-commits] [node-foreground-child] 46/69: replace cross-spawn-async with cross-spawn

Bastien Roucariès rouca at moszumanska.debian.org
Fri Aug 25 11:43:06 UTC 2017


This is an automated email from the git hooks/post-receive script.

rouca pushed a commit to branch master
in repository node-foreground-child.

commit b3477c2d77ef5813bc86c90fd70f0b457ea169a0
Author: Ryan Graham <r.m.graham at gmail.com>
Date:   Sat May 28 16:53:41 2016 -0700

    replace cross-spawn-async with cross-spawn
    
    The logic for checking whether cross-spawn-async needed to be called is
    implemented directly in cross-spawn, so also remove our version of the
    logic and the corresponding direct dependency on 'which'.
    
    Replaces #8
    Close #9
---
 index.js     | 37 +++----------------------------------
 package.json |  5 ++---
 2 files changed, 5 insertions(+), 37 deletions(-)

diff --git a/index.js b/index.js
index 04ae8af..aa48c6f 100644
--- a/index.js
+++ b/index.js
@@ -1,37 +1,7 @@
 var signalExit = require('signal-exit')
 var spawn = require('child_process').spawn
-var crossSpawn = require('cross-spawn-async')
-var fs = require('fs')
-var which = require('which')
-
-function needsCrossSpawn (exe) {
-  if (process.platform !== 'win32') {
-    return false
-  }
-
-  try {
-    exe = which.sync(exe)
-  } catch (er) {
-    // failure to find the file?  cmd probably needed.
-    return true
-  }
-
-  if (/\.(com|cmd|bat)$/i.test(exe)) {
-    // need cmd.exe to run command and batch files
-    return true
-  }
-
-  var buffer = new Buffer(150)
-  try {
-    var fd = fs.openSync(exe, 'r')
-    fs.readSync(fd, buffer, 0, 150, 0)
-  } catch (e) {
-    // If it's not an actual file, probably it needs cmd.exe.
-    // also, would be unsafe to test arbitrary memory on next line!
-    return true
-  }
-
-  return /\#\!(.+)/i.test(buffer.toString().trim())
+if (process.platform === 'win32') {
+  spawn = require('cross-spawn')
 }
 
 module.exports = function (program, args, cb) {
@@ -66,8 +36,7 @@ module.exports = function (program, args, cb) {
     spawnOpts.stdio.push('ipc')
   }
 
-  var spawnfn = needsCrossSpawn(program) ? crossSpawn : spawn
-  var child = spawnfn(program, args, spawnOpts)
+  var child = spawn(program, args, spawnOpts)
 
   var childExited = false
   signalExit(function (code, signal) {
diff --git a/package.json b/package.json
index f956138..15bc4b7 100644
--- a/package.json
+++ b/package.json
@@ -7,9 +7,8 @@
     "test": "test"
   },
   "dependencies": {
-    "cross-spawn-async": "^2.1.1",
-    "signal-exit": "^2.0.0",
-    "which": "^1.2.1"
+    "cross-spawn": "^4",
+    "signal-exit": "^2.0.0"
   },
   "devDependencies": {
     "tap": "^5.1.1"

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/node-foreground-child.git



More information about the Pkg-javascript-commits mailing list