function spawn(exe, args, cwd) {
  return new Promise((resolve, reject) => {
    const child = cp.spawn(exe, args, {cwd: cwd || process.cwd()});
    const buffer = [];
    child.stderr.on('data', (chunk) => {
      buffer.push(chunk.toString());
    });
    child.stdout.on('data', (chunk) => {
      buffer.push(chunk.toString());
    });
    child.on('close', (code) => {
      const output = buffer.join('');
      if (code) {
        const msg = output || 'Process failed: ' + code;
        reject(new ProcessError(code, msg));
      } else {
        resolve(output);
      }
    });
  });
}
Util function for handling spawned processes as promises.
@param {string} exe Executable.
@param {Array<string>} args Arguments.
@param {string} cwd Working directory.
@return {Promise} A promise.