Util.exec = function()

in pipeline/local_modules/pipeline_utils/pipeline_utils.js [209:230]


Util.exec = function (command, options) {
  return new Promise(function (resolve, reject) {
    var child = childProcess.exec(command, options);

    var lastMessage = ""
    child.stdout.on('data', function (data) {
      lastMessage = data.toString('utf-8');
      process.stdout.write(data);
    });
    child.stderr.on('data', function (data) {
      lastMessage = data.toString('utf-8');
      process.stderr.write(data);
    });
    child.on('close', function (code) {
      if (!code) {
        resolve(true);
      } else {
        reject("Error(" + code + ") - " + lastMessage);
      }
    });
  });
}