Permalink
Browse files

exec: Handle spawn errors

  • Loading branch information...
1 parent f4c6c96 commit a37d157d359290fac029866c2d74df890eb8a815 @isaacs isaacs committed Mar 20, 2013
Showing with 3 additions and 0 deletions.
  1. +3 −0 lib/utils/exec.js
View
@@ -10,6 +10,7 @@ var log = require("npmlog")
, isRoot = process.getuid && myUID === 0
, constants = require("constants")
, uidNumber = require("uid-number")
+ , once = require("once")
function exec (cmd, args, env, takeOver, cwd, uid, gid, cb) {
if (typeof cb !== "function") cb = gid, gid = null
@@ -45,6 +46,8 @@ function exec (cmd, args, env, takeOver, cwd, uid, gid, cb) {
var stdout = ""
, stderr = ""
, cp = spawn(cmd, args, env, takeOver, cwd, uid, gid)
+ cb = once(cb)
+ cp.on("error", cb)
cp.stdout && cp.stdout.on("data", function (chunk) {
if (chunk) stdout += chunk
})

0 comments on commit a37d157

Please sign in to comment.