code: function spawn(cmd, args, opts) {
    const spawn = require('child_process').spawn;
    const _ = require('lodash');
    return new Promise((resolve, reject) => {
      const p = spawn(cmd, typeof args === 'string' ? args.split(' ') : args, _.merge({stdio: argv.quiet ? ['ignore', 'pipe', 'pipe'] : ['ignore', 1, 2]}, opts));
      const out = [];
      if (p.stdout) {
        p.stdout.on('data', (chunk) => out.push(chunk));
      }
      if (p.stderr) {
        p.stderr.on('data', (chunk) => out.push(chunk));
      }
      p.on('close', (code, signal) => {
        if (code === 0) {
          console.info(cmd, 'ok status code', code, signal);
          resolve(code);
        } else {
          console.error(cmd, 'status code', code, signal);
          if (args.quiet) {
            // log output what has been captured
            console.log(out.join('\n'));
          }
          reject(`${cmd} failed with status code ${code} ${signal}`);
        }
      });
    });
  }
docs: spawns a child process
  @param cmd command as array
  @param args arguments
  @param opts options
  @returns a promise with the result code or a reject with the error string