var spawn = require('child_process').spawn;

var task = {
    id         : 'run',
    author     : 'Indigo United',
    name       : 'Run',
    description: 'Run command',
    options    : {
        cmd: {
            description: 'What command to execute'
        },
        cwd: {
            description: 'Current working directory of the child process',
            'default': null
        }
    },
    tasks      :
    [
        {
            task: function (opt, next) {
                var child,
                    that = this;

                if (process.platform === 'win32') {
                    child = spawn('cmd', ['/s', '/c', opt.cmd], { cwd: opt.cwd });
                } else {
                    child = spawn('sh', ['-c', opt.cmd], { cwd: opt.cwd });
                }

                this.log.infoln('Running: '.green + opt.cmd + '\n');

                // Added colors support with the customFds option
                // If that is removed, we have access to the .stdout and .stderr again
                child.stdout.on('data', function (data) {
                    that.log.info(data.toString());
                });

                child.stderr.on('data', function (data) {
                    // Log stderr as normal messages because a lot of programs
                    // output debug messages to stderr (and not only error messages)
                    // This is a valid standard
                    that.log.info(data.toString());
                });

                child.on('exit', function (code) {
                    if (code === 0) {
                        return next();
                    }

                    next(new Error('Error running command: ' + opt.cmd));
                }.bind(this));
            }
        }
    ]
};

module.exports = task;
@@ -528,16 +528,77 @@
 t = this
+,%0A                    output = '',%0A                    onData
 ;%0A%0A     
@@ -937,144 +937,102 @@
     
-// Added colors support with the customFds option%0A                // If that is removed, we have access to the .stdout and .stderr aga
+onData = function (data) %7B%0A                    // Buffer the response until we find a new l
 in
+e
 %0A   
@@ -1048,259 +1048,272 @@
     
-child.stdout.on('data', function (data) %7B%0A                    that.log.info(data.toString());%0A                %7D);%0A%0A                child.stderr.on('data', function (data) %7B%0A                    // Log stderr as normal messages because a lot of programs
+    output += data.toString();%0A%0A                    var pos = output.lastIndexOf('%5Cn');%0A                    if (pos !== -1) %7B%0A                        // If there is a new line in the buffer, output it%0A                        that.log.infoln(output.substr(0, pos));
 %0A   
@@ -1333,18 +1333,19 @@
     
-//
+   
  output 
 debu
@@ -1344,63 +1344,41 @@
 put 
-debug messages to stderr (and not only error messages)%0A
+= output.substr(pos + 1);%0A       
     
@@ -1390,166 +1390,333 @@
     
+%7D%0A
        
-// This is a valid standard%0A                    that.log.info(data.toString());%0A                %7D);%0A%0A                child.on('exit', function (code) %7B
+         %7D;%0A%0A                child.stdout.on('data', onData);%0A                child.stderr.on('data', onData);%0A%0A                child.on('exit', function (code) %7B%0A                    // Log the remaining buffer%0A                    if (output) %7B%0A                        this.log.infoln(output);%0A                    %7D%0A
 %0A   

Fix logging in the run task.