Skip to content
Browse files

opts.showCommand

  • Loading branch information...
1 parent a1a57b0 commit cd5088e9493ea40cdd50a2629be7b651e047d41f @substack committed Oct 4, 2012
Showing with 12 additions and 2 deletions.
  1. +7 −1 index.js
  2. +1 −1 package.json
  3. +4 −0 readme.markdown
View
8 index.js
@@ -16,7 +16,13 @@ module.exports = function (cmd, args, opts) {
ps.on('close', function (code) {
if (code === 0) return;
- dup.emit('error', new Error('non-zero exit code ' + code + ': ' + err));
+ dup.emit('error', new Error(
+ 'non-zero exit code ' + code
+ + (!opts || opts.showCommand !== false
+ ? '\n while running: ' + cmd + ' ' + args.join(' ')
+ : ''
+ )
+ + '\n\n ' + err));
});
var dup = duplexer(ps.stdin, ps.stdout);
View
2 package.json
@@ -1,6 +1,6 @@
{
"name" : "comandante",
- "version" : "0.0.0",
+ "version" : "0.0.1",
"description" : "spawn() that returns a duplex stream and emits errors with stderr data on non-zero exit codes",
"main" : "index.js",
"bin" : {},
4 readme.markdown
@@ -52,6 +52,10 @@ value is a duplex stream combining `stdout` and `stdin`.
If the process exits with a non-zero status, emit an `'error'` event with the
stderr data and the code in an informative message.
+If `opts.showCommand` is not `false`, show the actual command in the informative
+error message. If you are running a command with passwords in the command
+arguments make sure to set `showCommand` to `false`.
+
# install
With [npm](https://npmjs.org) do:

0 comments on commit cd5088e

Please sign in to comment.
Something went wrong with that request. Please try again.