index.js
function _spawn(mvn, args) {
  const spawn = require('child_process').spawn;
  // Command to be executed.
  let cmd = mvn.options.cmd || mvnw(mvn.options.cwd) || 'mvn';
  return new Promise((resolve, reject) => {
    if (isWin) {
      args.unshift(cmd);
      args.unshift('/c'),
      args.unshift('/s');
      cmd = process.env.COMSPEC || 'cmd.exe';
    }
    const proc = spawn(cmd, args, { 'cwd': mvn.options.cwd });
    proc.on('error', reject);
    proc.on('exit', (code, signal) => {
      if (code !== 0) {
        reject({ 'code': code, 'signal': signal });
      } else {
        resolve();
      }
    });
    proc.stdout.on('data', process.stdout.write.bind(process.stdout));
    proc.stderr.on('data', process.stderr.write.bind(process.stderr));
  });
}
function _spawn(mvn, args) {
  const spawn = require('child_process').spawn;
  // Command to be executed.
  let cmd = mvn.options.cmd || mvnw(mvn.options.cwd) || 'mvn';
  return new Promise((resolve, reject) => {
    if (isWin) {
      args.unshift(cmd);
      args.unshift('/c'),
      args.unshift('/s');
      cmd = process.env.COMSPEC || 'cmd.exe';
    }
    const proc = spawn(cmd, args, { 'cwd': mvn.options.cwd });
    proc.on('error', reject);
    proc.on('exit', (code, signal) => {
      if (code !== 0) {
        reject({ 'code': code, 'signal': signal });
      } else {
        resolve();
      }
    });
    proc.stdout.on('data', process.stdout.write.bind(process.stdout));
    proc.stderr.on('data', process.stderr.write.bind(process.stderr));
  });
}
function _spawn ( mvn , args ) { const spawn = require ( 'child_process' ) . spawn ; // Command to be executed. let cmd = mvn . options . cmd || mvnw ( mvn . options . cwd ) || 'mvn' ; return new Promise ( ( resolve , reject ) => { if ( isWin ) { args . unshift ( cmd ) ; args . unshift ( '/c' ) , args . unshift ( '/s' ) ; cmd = process . env . COMSPEC || 'cmd.exe' ; } const proc = spawn ( cmd , args , { 'cwd' : mvn . options . cwd } ) ; proc . on ( 'error' , reject ) ; proc . on ( 'exit' , ( code , signal ) => { if ( code !== 0 ) { reject ( { 'code' : code , 'signal' : signal } ) ; } else { resolve ( ) ; } } ) ; proc . stdout . on ( 'data' , process . stdout . write . bind ( process . stdout ) ) ; proc . stderr . on ( 'data' , process . stderr . write . bind ( process . stderr ) ) ; } ) ; }
A simple wrapper around child_process.spawn that returns a promise.
@private
@param {!Maven} mvn
@param {!Array.<string>} args
Command to be executed.
@return {Promise.<void>}
A simple wrapper around child_process . spawn that returns a promise .