text: /*!
   * @nuxt/cli v2.10.2 (c) 2016-2019
  
   * - All the amazing contributors
   * Released under the MIT License.
   * Website: https://nuxtjs.org
  */
  'use strict';
  
  Object.defineProperty(exports, '__esModule', { value: true });
  
  function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; }
  
  const command = require('./cli-command.js');
  require('path');
  require('@nuxt/config');
  const exit = _interopDefault(require('exit'));
  require('@nuxt/utils');
  require('chalk');
  require('std-env');
  require('wrap-ansi');
  require('boxen');
  const index$1 = require('./cli-index.js');
  const consola = _interopDefault(require('consola'));
  require('minimist');
  require('hable');
  require('esm');
  const fs = _interopDefault(require('fs'));
  const execa = _interopDefault(require('execa'));
  
  let _setup = false;
  
  function setup ({ dev }) {
    // Apply default NODE_ENV if not provided
    if (!process.env.NODE_ENV) {
      process.env.NODE_ENV = dev ? 'development' : 'production';
    }
  
    if (_setup) {
      return
    }
    _setup = true;
  
    // Global error handler
    /* istanbul ignore next */
    process.on('unhandledRejection', (err) => {
      consola.error(err);
    });
  
    // Exit process on fatal errors
    /* istanbul ignore next */
    consola.addReporter({
      log (logObj) {
        if (logObj.type === 'fatal') {
          const errorMessage = String(logObj.args[0]);
          process.stderr.write(index$1.fatalBox(errorMessage));
          exit(1);
        }
      }
    });
  
    // Wrap all console logs with consola for better DX
    consola.wrapConsole();
  }
  
  function packageExists (name) {
    try {
      require.resolve(name);
      return true
    } catch (e) {
      return false
    }
  }
  
  async function run (_argv, hooks = {}) {
    // Check for not installing both nuxt and nuxt-edge
    const dupPkg = '@nuxt/' + ( 'cli-edge');
    if (packageExists(dupPkg)) {
      throw new Error('Both `nuxt` and `nuxt-edge` dependencies are installed! This is unsupported, please choose one and remove the other one from dependencies.')
    }
  
    // Read from process.argv
    const argv = _argv ? Array.from(_argv) : process.argv.slice(2);
  
    // Check for internal command
    let cmd = await command.getCommand(argv[0]);
  
    // Matching `nuxt` or `nuxt [dir]` or `nuxt -*` for `nuxt dev` shortcut
    if (!cmd && (!argv[0] || argv[0][0] === '-' || fs.existsSync(argv[0]))) {
      argv.unshift('dev');
      cmd = await command.getCommand('dev');
    }
  
    // Check for dev
    const dev = argv[0] === 'dev';
  
    // Setup env
    setup({ dev });
  
    // Try internal command
    if (cmd) {
      return command.NuxtCommand.run(cmd, argv.slice(1), hooks)
    }
  
    // Try external command
    try {
      await execa(`nuxt-${argv[0]}`, argv.slice(1), {
        stdout: process.stdout,
        stderr: process.stderr,
        stdin: process.stdin
      });
    } catch (error) {
      if (error.exitCode === 2) {
        throw String(`Command not found: nuxt-${argv[0]}`)
      }
      throw String(`Failed to run command \`nuxt-${argv[0]}\`:\n${error}`)
    }
  }
  
  exports.NuxtCommand = command.NuxtCommand;
  exports.commands = command.index;
  exports.imports = command.imports;
  exports.loadNuxtConfig = command.loadNuxtConfig;
  exports.options = index$1.index;
  exports.run = run;
  exports.setup = setup;
  