"use strict";

var _require = require('child_process'),
    spawn = _require.spawn;

var spawnWin = require('cross-spawn');

module.exports = function exec(command, args, opts) {
  return new Promise(function (resolve, reject) {
    var child = process.platform === 'win32' ? spawnWin(command, args, Object.assign({
      stdio: 'inherit',
      env: process.env
    }, opts)) : spawn(command, args, Object.assign({
      stdio: 'inherit',
      env: process.env
    }, opts));
    child.once('error', function (err) {
      console.log(err);
      reject(err);
    });
    child.once('close', function (code) {
      if (code === 1) {
        process.exit(1);
      } else {
        resolve();
      }
    });
  });
};