'use strict';

var Promise = require('../ext/promise');
var exec    = Promise.denodeify(require('child_process').exec);
var chalk   = require('chalk');
var ui      = require('../ui');

module.exports = function runCommand(command, startedMsg) {
  return function() {
    ui.write('\n');
    ui.pleasantProgress.start(startedMsg);

    return exec(command, { maxBuffer: 1000 * 1024 }).then(function() {
      ui.write(chalk.green('done'));
    }, error);
  };
};

function error(err) {
  ui.write('\n' + chalk.red(err) + '\n');
}


@@ -493,15 +493,8 @@
 ite(
-'%5Cn' + 
 chal
@@ -503,19 +503,74 @@
 red(
-err) + '%5Cn'
+'%5CnError thrown while running shell command%5Cn%5Cn'));%0A  ui.write(err
 );%0A%7D

update run command error message