forked from npm/cli
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
include command in spawn errors (fixes npm#3908)
factor to centralize wrap child, make it aware of filename
- Loading branch information
Showing
8 changed files
with
69 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
module.exports = spawn | ||
|
||
var _spawn = require("child_process").spawn, | ||
EventEmitter = require("events").EventEmitter | ||
|
||
function spawn (cmd, args, options) { | ||
var raw = _spawn(cmd, args, options) | ||
cooked = new EventEmitter() | ||
|
||
raw.on("error", function (er) { | ||
er.file = cmd | ||
cooked.emit("error", er) | ||
}).on("close", function (code, signal) { | ||
cooked.emit("close", code, signal) | ||
}) | ||
|
||
cooked.stdin = raw.stdin | ||
cooked.stdout = raw.stdout | ||
cooked.stderr = raw.stderr | ||
|
||
return cooked | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
var path = require("path") | ||
var test = require("tap").test | ||
var rimraf = require("rimraf") | ||
var mkdirp = require("mkdirp") | ||
var common = require("../common-tap.js") | ||
|
||
var pkg = path.resolve(__dirname, "spawn-enoent-help") | ||
|
||
test("setup", function (t) { | ||
rimraf.sync(pkg) | ||
mkdirp.sync(pkg) | ||
t.end() | ||
}) | ||
|
||
test("enoent help", function (t) { | ||
common.npm(["help", "config"], { | ||
cwd: pkg, | ||
env: { | ||
PATH: "", | ||
Path: "", | ||
"npm_config_loglevel": "warn", | ||
"npm_config_viewer": "woman" | ||
} | ||
}, function (er, code, sout, serr) { | ||
t.similar(serr, /Check if the file 'emacsclient' is present./) | ||
t.end() | ||
}) | ||
}) | ||
|
||
test("clean", function (t) { | ||
rimraf.sync(pkg) | ||
t.end() | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters