Skip to content

Commit

Permalink
output cmd process on stdout. Preserved colored output.
Browse files Browse the repository at this point in the history
  • Loading branch information
elmasse committed Mar 25, 2015
1 parent 9ea52ec commit f9c81c0
Showing 1 changed file with 2 additions and 23 deletions.
25 changes: 2 additions & 23 deletions src/cmd/withSpawn.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,29 +7,8 @@ cocktail.mix({
'@exports': module,
'@as': 'class',

'@requires': [
'getArgs'
],

runSpawn: function (which, args) {
this._attachSpawnListeners(spawn(which, args));
},

_attachSpawnListeners: function (spawnInstance) {
var me = this;
me._attachEventListener('data', spawnInstance.stdout, me._onProgress);
me._attachEventListener('error', spawnInstance.stderr, me._onError);
},

_attachEventListener: function (event, stream, mthd) {
stream.on(event, mthd.bind(this));
},

_onProgress: function (data) {
console.log('' + data);
},

_onError: function (data) {
console.error('Error: ' + data);
spawn(which, args, {stdio: "inherit"});
}

});

0 comments on commit f9c81c0

Please sign in to comment.