Permalink
Browse files

Provide an option to handle the data event

  • Loading branch information...
qawemlilo committed Sep 30, 2013
1 parent 0ca31e9 commit 2d97c3c71c4f12cb3509c018d55801a92d7ec50e
Showing with 4 additions and 2 deletions.
  1. +4 −2 tasks/exec.js
View
@@ -17,6 +17,8 @@ module.exports = function(grunt) {
, stdout = data.stdout !== undefined ? data.stdout : true
, stderr = data.stderr !== undefined ? data.stderr : true
, callback = _.isFunction(data.callback) ? data.callback : function() {}
, onOutData = _.isFunction(data.onOutData) ? data.onOutData : function (d) { log.write(d); }
, onErrData = _.isFunction(data.onErrData) ? data.onErrData : function (d) { log.write(d); }
, exitCode = data.exitCode || 0
, command
, childProcess
@@ -49,8 +51,8 @@ module.exports = function(grunt) {
childProcess = cp.exec(command, execOptions, callback);
stdout && childProcess.stdout.on('data', function (d) { log.write(d); });
stderr && childProcess.stderr.on('data', function (d) { log.error(d); });
stdout && childProcess.stdout.on('data', onOutData);
stderr && childProcess.stderr.on('data', onErrData);
childProcess.on('exit', function(code) {
if (code !== exitCode) {

0 comments on commit 2d97c3c

Please sign in to comment.