text: "use strict";
  
  var _chalk = _interopRequireDefault(require("chalk"));
  
  var _interpret = _interopRequireDefault(require("interpret"));
  
  var _v8flags = _interopRequireDefault(require("v8flags"));
  
  var _liftoff = _interopRequireDefault(require("liftoff"));
  
  var _commander = _interopRequireDefault(require("commander"));
  
  var _Shipit = _interopRequireDefault(require("./Shipit"));
  
  var _package = _interopRequireDefault(require("../package.json"));
  
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  
  function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
  
  function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
  
  function exit(code) {
    if (process.platform === 'win32' && process.stdout.bufferSize) {
      process.stdout.once('drain', () => {
        process.exit(code);
      });
      return;
    }
  
    process.exit(code);
  }
  
  _commander.default.version(_package.default.version).allowUnknownOption().usage('<environment> <tasks...>').option('--shipitfile <file>', 'Specify a custom shipitfile to use').option('--require <files...>', 'Script required before launching Shipit').option('--tasks', 'List available tasks').option('--environments', 'List available environments');
  
  _commander.default.parse(process.argv);
  
  if (!process.argv.slice(2).length) {
    _commander.default.help();
  }
  
  function logTasks(shipit) {
    console.log(Object.keys(shipit.tasks).join('\n').trim());
  }
  
  function logEnvironments(shipit) {
    console.log(Object.keys(shipit.globalConfig).join('\n').trim());
  }
  
  function asyncInvoke(_x) {
    return _asyncInvoke.apply(this, arguments);
  }
  
  function _asyncInvoke() {
    _asyncInvoke = _asyncToGenerator(function* (env) {
      if (!env.configPath) {
        console.error(_chalk.default.red('shipitfile not found'));
        exit(1);
      }
  
      const _program$args = _commander.default.args,
            environment = _program$args[0],
            tasks = _program$args.slice(1);
  
      const shipit = new _Shipit.default({
        environment
      });
  
      try {
        /* eslint-disable global-require, import/no-dynamic-import, import/no-dynamic-require */
        const module = require(env.configPath);
        /* eslint-enable global-require, import/no-dynamic-import, import/no-dynamic-require */
  
  
        const initialize = typeof module.default === 'function' ? module.default : module;
        yield initialize(shipit);
      } catch (error) {
        console.error(_chalk.default.red('Could not load async config'));
        throw error;
      }
  
      if (_commander.default.tasks === true) {
        logTasks(shipit);
      } else if (_commander.default.environments === true) {
        logEnvironments(shipit);
      } else {
        // Run the 'default' task if no task is specified
        const runTasks = tasks.length === 0 ? ['default'] : tasks;
        shipit.initialize();
        shipit.on('task_err', () => exit(1));
        shipit.on('task_not_found', () => exit(1));
        shipit.start(runTasks);
      }
    });
    return _asyncInvoke.apply(this, arguments);
  }
  
  function invoke(env) {
    asyncInvoke(env).catch(error => {
      setTimeout(() => {
        throw error;
      });
    });
  }
  
  const cli = new _liftoff.default({
    name: 'shipit',
    extensions: _interpret.default.jsVariants,
    v8flags: _v8flags.default
  });
  cli.launch({
    configPath: _commander.default.shipitfile,
    require: _commander.default.require
  }, invoke);