bin/index.js

Summary

Maintainability
A
0 mins
Test Coverage
/******/ (function(modules) { // webpackBootstrap
/******/     // The module cache
/******/     var installedModules = {};
/******/
/******/     // The require function
/******/     function __webpack_require__(moduleId) {
/******/
/******/         // Check if module is in cache
/******/         if(installedModules[moduleId]) {
/******/             return installedModules[moduleId].exports;
/******/         }
/******/         // Create a new module (and put it into the cache)
/******/         var module = installedModules[moduleId] = {
/******/             i: moduleId,
/******/             l: false,
/******/             exports: {}
/******/         };
/******/
/******/         // Execute the module function
/******/         modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
/******/
/******/         // Flag the module as loaded
/******/         module.l = true;
/******/
/******/         // Return the exports of the module
/******/         return module.exports;
/******/     }
/******/
/******/
/******/     // expose the modules object (__webpack_modules__)
/******/     __webpack_require__.m = modules;
/******/
/******/     // expose the module cache
/******/     __webpack_require__.c = installedModules;
/******/
/******/     // define getter function for harmony exports
/******/     __webpack_require__.d = function(exports, name, getter) {
/******/         if(!__webpack_require__.o(exports, name)) {
/******/             Object.defineProperty(exports, name, { enumerable: true, get: getter });
/******/         }
/******/     };
/******/
/******/     // define __esModule on exports
/******/     __webpack_require__.r = function(exports) {
/******/         if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
/******/             Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
/******/         }
/******/         Object.defineProperty(exports, '__esModule', { value: true });
/******/     };
/******/
/******/     // create a fake namespace object
/******/     // mode & 1: value is a module id, require it
/******/     // mode & 2: merge all properties of value into the ns
/******/     // mode & 4: return value when already ns object
/******/     // mode & 8|1: behave like require
/******/     __webpack_require__.t = function(value, mode) {
/******/         if(mode & 1) value = __webpack_require__(value);
/******/         if(mode & 8) return value;
/******/         if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;
/******/         var ns = Object.create(null);
/******/         __webpack_require__.r(ns);
/******/         Object.defineProperty(ns, 'default', { enumerable: true, value: value });
/******/         if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));
/******/         return ns;
/******/     };
/******/
/******/     // getDefaultExport function for compatibility with non-harmony modules
/******/     __webpack_require__.n = function(module) {
/******/         var getter = module && module.__esModule ?
/******/             function getDefault() { return module['default']; } :
/******/             function getModuleExports() { return module; };
/******/         __webpack_require__.d(getter, 'a', getter);
/******/         return getter;
/******/     };
/******/
/******/     // Object.prototype.hasOwnProperty.call
/******/     __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
/******/
/******/     // __webpack_public_path__
/******/     __webpack_require__.p = "";
/******/
/******/
/******/     // Load entry module and return exports
/******/     return __webpack_require__(__webpack_require__.s = "./bin/index.ts");
/******/ })
/************************************************************************/
/******/ ({

/***/ "./bin/index.ts":
/*!**********************!*\
  !*** ./bin/index.ts ***!
  \**********************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {

"use strict";
eval("\nvar __spreadArrays = (this && this.__spreadArrays) || function () {\n    for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;\n    for (var r = Array(s), k = 0, i = 0; i < il; i++)\n        for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)\n            r[k] = a[j];\n    return r;\n};\nexports.__esModule = true;\nvar program = __webpack_require__(/*! commander */ \"./node_modules/commander/index.js\");\nvar path = __webpack_require__(/*! path */ \"path\");\nvar create_sym_link_1 = __webpack_require__(/*! ../lib/create-sym-link */ \"./lib/create-sym-link.ts\");\nvar options_1 = __webpack_require__(/*! ../lib/options */ \"./lib/options.ts\");\nvar rewrite_iframe_src_1 = __webpack_require__(/*! ../lib/rewrite-iframe-src */ \"./lib/rewrite-iframe-src.ts\");\nvar reload_1 = __webpack_require__(/*! ../lib/reload */ \"./lib/reload.ts\");\nprogram\n    .name('resv')\n    .usage('<directory or url> [options]')\n    .option('-w, --watch-dir [directory]', 'The directory to watch. Defaults the serving directory or file')\n    .option('-e, --exts [extensions]', 'Extensions separated by commas or pipes. (default: html,css,sass,scss,js,jsx,tsx,vue,php,rb,go,py)')\n    .option('-p, --port [port]', 'The port to bind to. Defaults to 8080 (default: \"8080\")');\nprogram.on('--help', function () {\n    console.log();\n    console.log('For more information, see');\n    console.log('https://github.com/hktysk/resv');\n    console.log();\n});\nfunction main(argv) {\n    var target = argv.args.length > 0 ? argv.args[0] : process.cwd();\n    if (target.slice(0, 7) !== 'http://' && target.slice(0, 8) !== 'https://') {\n        if (target.slice(0, 1) !== '/') {\n            /* If 'target' is a relative path, change it to an absolute path */\n            target = path.join(process.cwd(), target);\n        }\n        /*\n          When the server is set up,\n          only the files under resv/assets/ can be specified,\n          so create the target directory as a symbolic link under resv/assets/\n        */\n        var created = create_sym_link_1[\"default\"](target);\n        if (created === false)\n            return;\n    }\n    var options = __spreadArrays(options_1.watch(argv.watchDir, target), options_1.exts(argv.exts), options_1.port(argv.port));\n    /* Rewrite target-url.js to set src path of iframe */\n    rewrite_iframe_src_1[\"default\"](target.slice(0, 1) === '/' ? 'sym/index.html' : target);\n    /* execute reload module */\n    var watchPath = options[1];\n    reload_1[\"default\"](watchPath, options);\n}\nmain(program.parse(process.argv));\n\n\n//# sourceURL=webpack:///./bin/index.ts?");

/***/ }),

/***/ "./lib/create-sym-link.ts":
/*!********************************!*\
  !*** ./lib/create-sym-link.ts ***!
  \********************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {

"use strict";
eval("\nexports.__esModule = true;\nvar path = __webpack_require__(/*! path */ \"path\");\nvar fs = __webpack_require__(/*! fs */ \"fs\");\nfunction createSymLink(target) {\n    /* Check if 'index.html' exists in the directory */\n    try {\n        fs.statSync(path.join(target, 'index.html'));\n    }\n    catch (err) {\n        console.log('file or directory does not exist.');\n        console.log('please specify the directory that index.html is located or URL.');\n        return false;\n    }\n    /* Create symbolic link */\n    var sym = path.join(__dirname, '../assets/sym');\n    try {\n        fs.lstatSync(sym).isSymbolicLink();\n        fs.unlinkSync(sym);\n        fs.symlinkSync(target, sym);\n    }\n    catch (err) {\n        if (err.code === 'ENOENT') {\n            fs.symlinkSync(target, sym);\n        }\n    }\n    return true;\n}\nexports[\"default\"] = createSymLink;\n\n\n//# sourceURL=webpack:///./lib/create-sym-link.ts?");

/***/ }),

/***/ "./lib/options.ts":
/*!************************!*\
  !*** ./lib/options.ts ***!
  \************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {

"use strict";
eval("\nvar __spreadArrays = (this && this.__spreadArrays) || function () {\n    for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;\n    for (var r = Array(s), k = 0, i = 0; i < il; i++)\n        for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)\n            r[k] = a[j];\n    return r;\n};\nexports.__esModule = true;\nvar path = __webpack_require__(/*! path */ \"path\");\nfunction watch(watchDir, target) {\n    /*\n      watch directory option.\n      If --watch-dir is not specified, watch target directory\n    */\n    var watchPath = watchDir || target;\n    if (target.slice(0, 7) !== 'http://' && target.slice(0, 8) !== 'https://') {\n        if (watchPath.slice(0, 1) !== '/') {\n            watchPath = path.join(__dirname, watchPath);\n        }\n    }\n    return ['--watch-dir', watchPath];\n}\nexports.watch = watch;\nfunction exts(extensinos) {\n    var exts = extensinos ? extensinos.split(/(\\||,)/) : [];\n    var defaultExts = ['html', 'css', 'sass', 'scss', 'js', 'jsx', 'tsx', 'vue', 'php', 'rb', 'go', 'py'];\n    exts = Array.from(new Set(__spreadArrays(exts, defaultExts)));\n    return ['--exts', exts.join(',')];\n}\nexports.exts = exts;\nfunction port(port) {\n    return port ? ['--port', port] : [];\n}\nexports.port = port;\n\n\n//# sourceURL=webpack:///./lib/options.ts?");

/***/ }),

/***/ "./lib/reload.ts":
/*!***********************!*\
  !*** ./lib/reload.ts ***!
  \***********************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {

"use strict";
eval("\nvar __spreadArrays = (this && this.__spreadArrays) || function () {\n    for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;\n    for (var r = Array(s), k = 0, i = 0; i < il; i++)\n        for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)\n            r[k] = a[j];\n    return r;\n};\nexports.__esModule = true;\nvar path = __webpack_require__(/*! path */ \"path\");\nvar fs = __webpack_require__(/*! fs */ \"fs\");\nvar child_process_1 = __webpack_require__(/*! child_process */ \"child_process\");\n/*\n  Use the reload module to update the browser.\n  more: https://www.npmjs.com/package/reload\n*/\nfunction reload(watchPath, options) {\n    var reload;\n    var modulesPath = path.join(__dirname, '../node_modules');\n    var opts = __spreadArrays(['-b', '-d', path.join(__dirname, '../assets')], options);\n    try {\n        reload = path.join(modulesPath, '.bin/reload');\n        fs.statSync(reload);\n    }\n    catch (err) {\n        if (err.code === 'ENOENT') {\n            reload = 'npx';\n            opts.unshift('reload');\n        }\n    }\n    var s = child_process_1.spawn(reload, opts);\n    s.stdout.setEncoding('utf8');\n    s.stdout.on('data', function (data) {\n        console.log(data\n            .replace('Reload web server:', 'resv started!')\n            .replace('monitoring dir', 'monitoring')\n            .replace(path.join(__dirname, '../assets'), watchPath));\n    });\n    s.on('error', function () { return process.exit(0); });\n    s.on('exit', function () { return process.exit(0); });\n}\nexports[\"default\"] = reload;\n\n\n//# sourceURL=webpack:///./lib/reload.ts?");

/***/ }),

/***/ "./lib/rewrite-iframe-src.ts":
/*!***********************************!*\
  !*** ./lib/rewrite-iframe-src.ts ***!
  \***********************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {

"use strict";
eval("\nexports.__esModule = true;\nvar path = __webpack_require__(/*! path */ \"path\");\nvar fs = __webpack_require__(/*! fs */ \"fs\");\nfunction rewriteIframeSrc(url) {\n    var targetUrlPath = path.join(__dirname, '../assets/target-url.js');\n    var targetSetFile = fs.readFileSync(targetUrlPath)\n        .toString()\n        .split('\\n');\n    // rewrite\n    targetSetFile[0] = \"var targetUrl = '\" + url + \"'\";\n    fs.writeFileSync(targetUrlPath, targetSetFile.join('\\n'));\n}\nexports[\"default\"] = rewriteIframeSrc;\n\n\n//# sourceURL=webpack:///./lib/rewrite-iframe-src.ts?");

/***/ }),

/***/ "./node_modules/commander/index.js":
/*!*****************************************!*\
  !*** ./node_modules/commander/index.js ***!
  \*****************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {

eval("/**\n * Module dependencies.\n */\n\nvar EventEmitter = __webpack_require__(/*! events */ \"events\").EventEmitter;\nvar spawn = __webpack_require__(/*! child_process */ \"child_process\").spawn;\nvar path = __webpack_require__(/*! path */ \"path\");\nvar dirname = path.dirname;\nvar basename = path.basename;\nvar fs = __webpack_require__(/*! fs */ \"fs\");\n\n/**\n * Inherit `Command` from `EventEmitter.prototype`.\n */\n\n__webpack_require__(/*! util */ \"util\").inherits(Command, EventEmitter);\n\n/**\n * Expose the root command.\n */\n\nexports = module.exports = new Command();\n\n/**\n * Expose `Command`.\n */\n\nexports.Command = Command;\n\n/**\n * Expose `Option`.\n */\n\nexports.Option = Option;\n\n/**\n * Initialize a new `Option` with the given `flags` and `description`.\n *\n * @param {String} flags\n * @param {String} description\n * @api public\n */\n\nfunction Option(flags, description) {\n  this.flags = flags;\n  this.required = flags.indexOf('<') >= 0;\n  this.optional = flags.indexOf('[') >= 0;\n  this.negate = flags.indexOf('-no-') !== -1;\n  flags = flags.split(/[ ,|]+/);\n  if (flags.length > 1 && !/^[[<]/.test(flags[1])) this.short = flags.shift();\n  this.long = flags.shift();\n  this.description = description || '';\n}\n\n/**\n * Return option name.\n *\n * @return {String}\n * @api private\n */\n\nOption.prototype.name = function() {\n  return this.long.replace(/^--/, '');\n};\n\n/**\n * Return option name, in a camelcase format that can be used\n * as a object attribute key.\n *\n * @return {String}\n * @api private\n */\n\nOption.prototype.attributeName = function() {\n  return camelcase(this.name().replace(/^no-/, ''));\n};\n\n/**\n * Check if `arg` matches the short or long flag.\n *\n * @param {String} arg\n * @return {Boolean}\n * @api private\n */\n\nOption.prototype.is = function(arg) {\n  return this.short === arg || this.long === arg;\n};\n\n/**\n * Initialize a new `Command`.\n *\n * @param {String} name\n * @api public\n */\n\nfunction Command(name) {\n  this.commands = [];\n  this.options = [];\n  this._execs = new Set();\n  this._allowUnknownOption = false;\n  this._args = [];\n  this._name = name || '';\n\n  this._helpFlags = '-h, --help';\n  this._helpDescription = 'output usage information';\n  this._helpShortFlag = '-h';\n  this._helpLongFlag = '--help';\n}\n\n/**\n * Define a command.\n *\n * There are two styles of command: pay attention to where to put the description.\n *\n * Examples:\n *\n *      // Command implemented using action handler (description is supplied separately to `.command`)\n *      program\n *        .command('clone <source> [destination]')\n *        .description('clone a repository into a newly created directory')\n *        .action((source, destination) => {\n *          console.log('clone command called');\n *        });\n *\n *      // Command implemented using separate executable file (description is second parameter to `.command`)\n *      program\n *        .command('start <service>', 'start named service')\n *        .command('stop [service]', 'stop named serice, or all if no name supplied');\n *\n * @param {string} nameAndArgs - command name and arguments, args are `<required>` or `[optional]` and last may also be `variadic...`\n * @param {Object|string} [actionOptsOrExecDesc] - configuration options (for action), or description (for executable)\n * @param {Object} [execOpts] - configuration options (for executable)\n * @return {Command} returns new command for action handler, or top-level command for executable command\n * @api public\n */\n\nCommand.prototype.command = function(nameAndArgs, actionOptsOrExecDesc, execOpts) {\n  var desc = actionOptsOrExecDesc;\n  var opts = execOpts;\n  if (typeof desc === 'object' && desc !== null) {\n    opts = desc;\n    desc = null;\n  }\n  opts = opts || {};\n  var args = nameAndArgs.split(/ +/);\n  var cmd = new Command(args.shift());\n\n  if (desc) {\n    cmd.description(desc);\n    this.executables = true;\n    this._execs.add(cmd._name);\n    if (opts.isDefault) this.defaultExecutable = cmd._name;\n  }\n  cmd._noHelp = !!opts.noHelp;\n  cmd._helpFlags = this._helpFlags;\n  cmd._helpDescription = this._helpDescription;\n  cmd._helpShortFlag = this._helpShortFlag;\n  cmd._helpLongFlag = this._helpLongFlag;\n  cmd._executableFile = opts.executableFile; // Custom name for executable file\n  this.commands.push(cmd);\n  cmd.parseExpectedArgs(args);\n  cmd.parent = this;\n\n  if (desc) return this;\n  return cmd;\n};\n\n/**\n * Define argument syntax for the top-level command.\n *\n * @api public\n */\n\nCommand.prototype.arguments = function(desc) {\n  return this.parseExpectedArgs(desc.split(/ +/));\n};\n\n/**\n * Add an implicit `help [cmd]` subcommand\n * which invokes `--help` for the given command.\n *\n * @api private\n */\n\nCommand.prototype.addImplicitHelpCommand = function() {\n  this.command('help [cmd]', 'display help for [cmd]');\n};\n\n/**\n * Parse expected `args`.\n *\n * For example `[\"[type]\"]` becomes `[{ required: false, name: 'type' }]`.\n *\n * @param {Array} args\n * @return {Command} for chaining\n * @api public\n */\n\nCommand.prototype.parseExpectedArgs = function(args) {\n  if (!args.length) return;\n  var self = this;\n  args.forEach(function(arg) {\n    var argDetails = {\n      required: false,\n      name: '',\n      variadic: false\n    };\n\n    switch (arg[0]) {\n      case '<':\n        argDetails.required = true;\n        argDetails.name = arg.slice(1, -1);\n        break;\n      case '[':\n        argDetails.name = arg.slice(1, -1);\n        break;\n    }\n\n    if (argDetails.name.length > 3 && argDetails.name.slice(-3) === '...') {\n      argDetails.variadic = true;\n      argDetails.name = argDetails.name.slice(0, -3);\n    }\n    if (argDetails.name) {\n      self._args.push(argDetails);\n    }\n  });\n  return this;\n};\n\n/**\n * Register callback `fn` for the command.\n *\n * Examples:\n *\n *      program\n *        .command('help')\n *        .description('display verbose help')\n *        .action(function() {\n *           // output help here\n *        });\n *\n * @param {Function} fn\n * @return {Command} for chaining\n * @api public\n */\n\nCommand.prototype.action = function(fn) {\n  var self = this;\n  var listener = function(args, unknown) {\n    // Parse any so-far unknown options\n    args = args || [];\n    unknown = unknown || [];\n\n    var parsed = self.parseOptions(unknown);\n\n    // Output help if necessary\n    outputHelpIfNecessary(self, parsed.unknown);\n\n    // If there are still any unknown options, then we simply\n    // die, unless someone asked for help, in which case we give it\n    // to them, and then we die.\n    if (parsed.unknown.length > 0) {\n      self.unknownOption(parsed.unknown[0]);\n    }\n\n    // Leftover arguments need to be pushed back. Fixes issue #56\n    if (parsed.args.length) args = parsed.args.concat(args);\n\n    self._args.forEach(function(arg, i) {\n      if (arg.required && args[i] == null) {\n        self.missingArgument(arg.name);\n      } else if (arg.variadic) {\n        if (i !== self._args.length - 1) {\n          self.variadicArgNotLast(arg.name);\n        }\n\n        args[i] = args.splice(i);\n      }\n    });\n\n    // Always append ourselves to the end of the arguments,\n    // to make sure we match the number of arguments the user\n    // expects\n    if (self._args.length) {\n      args[self._args.length] = self;\n    } else {\n      args.push(self);\n    }\n\n    fn.apply(self, args);\n  };\n  var parent = this.parent || this;\n  var name = parent === this ? '*' : this._name;\n  parent.on('command:' + name, listener);\n  if (this._alias) parent.on('command:' + this._alias, listener);\n  return this;\n};\n\n/**\n * Define option with `flags`, `description` and optional\n * coercion `fn`.\n *\n * The `flags` string should contain both the short and long flags,\n * separated by comma, a pipe or space. The following are all valid\n * all will output this way when `--help` is used.\n *\n *    \"-p, --pepper\"\n *    \"-p|--pepper\"\n *    \"-p --pepper\"\n *\n * Examples:\n *\n *     // simple boolean defaulting to undefined\n *     program.option('-p, --pepper', 'add pepper');\n *\n *     program.pepper\n *     // => undefined\n *\n *     --pepper\n *     program.pepper\n *     // => true\n *\n *     // simple boolean defaulting to true (unless non-negated option is also defined)\n *     program.option('-C, --no-cheese', 'remove cheese');\n *\n *     program.cheese\n *     // => true\n *\n *     --no-cheese\n *     program.cheese\n *     // => false\n *\n *     // required argument\n *     program.option('-C, --chdir <path>', 'change the working directory');\n *\n *     --chdir /tmp\n *     program.chdir\n *     // => \"/tmp\"\n *\n *     // optional argument\n *     program.option('-c, --cheese [type]', 'add cheese [marble]');\n *\n * @param {String} flags\n * @param {String} description\n * @param {Function|*} [fn] or default\n * @param {*} [defaultValue]\n * @return {Command} for chaining\n * @api public\n */\n\nCommand.prototype.option = function(flags, description, fn, defaultValue) {\n  var self = this,\n    option = new Option(flags, description),\n    oname = option.name(),\n    name = option.attributeName();\n\n  // default as 3rd arg\n  if (typeof fn !== 'function') {\n    if (fn instanceof RegExp) {\n      // This is a bit simplistic (especially no error messages), and probably better handled by caller using custom option processing.\n      // No longer documented in README, but still present for backwards compatibility.\n      var regex = fn;\n      fn = function(val, def) {\n        var m = regex.exec(val);\n        return m ? m[0] : def;\n      };\n    } else {\n      defaultValue = fn;\n      fn = null;\n    }\n  }\n\n  // preassign default value for --no-*, [optional], <required>, or plain flag if boolean value\n  if (option.negate || option.optional || option.required || typeof defaultValue === 'boolean') {\n    // when --no-foo we make sure default is true, unless a --foo option is already defined\n    if (option.negate) {\n      var opts = self.opts();\n      defaultValue = Object.prototype.hasOwnProperty.call(opts, name) ? opts[name] : true;\n    }\n    // preassign only if we have a default\n    if (defaultValue !== undefined) {\n      self[name] = defaultValue;\n      option.defaultValue = defaultValue;\n    }\n  }\n\n  // register the option\n  this.options.push(option);\n\n  // when it's passed assign the value\n  // and conditionally invoke the callback\n  this.on('option:' + oname, function(val) {\n    // coercion\n    if (val !== null && fn) {\n      val = fn(val, self[name] === undefined ? defaultValue : self[name]);\n    }\n\n    // unassigned or boolean value\n    if (typeof self[name] === 'boolean' || typeof self[name] === 'undefined') {\n      // if no value, negate false, and we have a default, then use it!\n      if (val == null) {\n        self[name] = option.negate\n          ? false\n          : defaultValue || true;\n      } else {\n        self[name] = val;\n      }\n    } else if (val !== null) {\n      // reassign\n      self[name] = option.negate ? false : val;\n    }\n  });\n\n  return this;\n};\n\n/**\n * Allow unknown options on the command line.\n *\n * @param {Boolean} arg if `true` or omitted, no error will be thrown\n * for unknown options.\n * @api public\n */\nCommand.prototype.allowUnknownOption = function(arg) {\n  this._allowUnknownOption = arguments.length === 0 || arg;\n  return this;\n};\n\n/**\n * Parse `argv`, settings options and invoking commands when defined.\n *\n * @param {Array} argv\n * @return {Command} for chaining\n * @api public\n */\n\nCommand.prototype.parse = function(argv) {\n  // implicit help\n  if (this.executables) this.addImplicitHelpCommand();\n\n  // store raw args\n  this.rawArgs = argv;\n\n  // guess name\n  this._name = this._name || basename(argv[1], '.js');\n\n  // github-style sub-commands with no sub-command\n  if (this.executables && argv.length < 3 && !this.defaultExecutable) {\n    // this user needs help\n    argv.push(this._helpLongFlag);\n  }\n\n  // process argv\n  var normalized = this.normalize(argv.slice(2));\n  var parsed = this.parseOptions(normalized);\n  var args = this.args = parsed.args;\n\n  var result = this.parseArgs(this.args, parsed.unknown);\n\n  if (args[0] === 'help' && args.length === 1) this.help();\n\n  // <cmd> --help\n  if (args[0] === 'help') {\n    args[0] = args[1];\n    args[1] = this._helpLongFlag;\n  }\n\n  // executable sub-commands\n  // (Debugging note for future: args[0] is not right if an action has been called)\n  var name = result.args[0];\n  var subCommand = null;\n\n  // Look for subcommand\n  if (name) {\n    subCommand = this.commands.find(function(command) {\n      return command._name === name;\n    });\n  }\n\n  // Look for alias\n  if (!subCommand && name) {\n    subCommand = this.commands.find(function(command) {\n      return command.alias() === name;\n    });\n    if (subCommand) {\n      name = subCommand._name;\n      args[0] = name;\n    }\n  }\n\n  // Look for default subcommand\n  if (!subCommand && this.defaultExecutable) {\n    name = this.defaultExecutable;\n    args.unshift(name);\n    subCommand = this.commands.find(function(command) {\n      return command._name === name;\n    });\n  }\n\n  if (this._execs.has(name)) {\n    return this.executeSubCommand(argv, args, parsed.unknown, subCommand ? subCommand._executableFile : undefined);\n  }\n\n  return result;\n};\n\n/**\n * Execute a sub-command executable.\n *\n * @param {Array} argv\n * @param {Array} args\n * @param {Array} unknown\n * @param {String} specifySubcommand\n * @api private\n */\n\nCommand.prototype.executeSubCommand = function(argv, args, unknown, executableFile) {\n  args = args.concat(unknown);\n\n  if (!args.length) this.help();\n\n  var isExplicitJS = false; // Whether to use node to launch \"executable\"\n\n  // executable\n  var pm = argv[1];\n  // name of the subcommand, like `pm-install`\n  var bin = basename(pm, path.extname(pm)) + '-' + args[0];\n  if (executableFile != null) {\n    bin = executableFile;\n    // Check for same extensions as we scan for below so get consistent launch behaviour.\n    var executableExt = path.extname(executableFile);\n    isExplicitJS = executableExt === '.js' || executableExt === '.ts' || executableExt === '.mjs';\n  }\n\n  // In case of globally installed, get the base dir where executable\n  //  subcommand file should be located at\n  var baseDir;\n\n  var resolvedLink = fs.realpathSync(pm);\n\n  baseDir = dirname(resolvedLink);\n\n  // prefer local `./<bin>` to bin in the $PATH\n  var localBin = path.join(baseDir, bin);\n\n  // whether bin file is a js script with explicit `.js` or `.ts` extension\n  if (exists(localBin + '.js')) {\n    bin = localBin + '.js';\n    isExplicitJS = true;\n  } else if (exists(localBin + '.ts')) {\n    bin = localBin + '.ts';\n    isExplicitJS = true;\n  } else if (exists(localBin + '.mjs')) {\n    bin = localBin + '.mjs';\n    isExplicitJS = true;\n  } else if (exists(localBin)) {\n    bin = localBin;\n  }\n\n  args = args.slice(1);\n\n  var proc;\n  if (process.platform !== 'win32') {\n    if (isExplicitJS) {\n      args.unshift(bin);\n      // add executable arguments to spawn\n      args = incrementNodeInspectorPort(process.execArgv).concat(args);\n\n      proc = spawn(process.argv[0], args, { stdio: 'inherit', customFds: [0, 1, 2] });\n    } else {\n      proc = spawn(bin, args, { stdio: 'inherit', customFds: [0, 1, 2] });\n    }\n  } else {\n    args.unshift(bin);\n    // add executable arguments to spawn\n    args = incrementNodeInspectorPort(process.execArgv).concat(args);\n    proc = spawn(process.execPath, args, { stdio: 'inherit' });\n  }\n\n  var signals = ['SIGUSR1', 'SIGUSR2', 'SIGTERM', 'SIGINT', 'SIGHUP'];\n  signals.forEach(function(signal) {\n    process.on(signal, function() {\n      if (proc.killed === false && proc.exitCode === null) {\n        proc.kill(signal);\n      }\n    });\n  });\n  proc.on('close', process.exit.bind(process));\n  proc.on('error', function(err) {\n    if (err.code === 'ENOENT') {\n      console.error('error: %s(1) does not exist, try --help', bin);\n    } else if (err.code === 'EACCES') {\n      console.error('error: %s(1) not executable. try chmod or run with root', bin);\n    }\n    process.exit(1);\n  });\n\n  // Store the reference to the child process\n  this.runningCommand = proc;\n};\n\n/**\n * Normalize `args`, splitting joined short flags. For example\n * the arg \"-abc\" is equivalent to \"-a -b -c\".\n * This also normalizes equal sign and splits \"--abc=def\" into \"--abc def\".\n *\n * @param {Array} args\n * @return {Array}\n * @api private\n */\n\nCommand.prototype.normalize = function(args) {\n  var ret = [],\n    arg,\n    lastOpt,\n    index,\n    short,\n    opt;\n\n  for (var i = 0, len = args.length; i < len; ++i) {\n    arg = args[i];\n    if (i > 0) {\n      lastOpt = this.optionFor(args[i - 1]);\n    }\n\n    if (arg === '--') {\n      // Honor option terminator\n      ret = ret.concat(args.slice(i));\n      break;\n    } else if (lastOpt && lastOpt.required) {\n      ret.push(arg);\n    } else if (arg.length > 2 && arg[0] === '-' && arg[1] !== '-') {\n      short = arg.slice(0, 2);\n      opt = this.optionFor(short);\n      if (opt && (opt.required || opt.optional)) {\n        ret.push(short);\n        ret.push(arg.slice(2));\n      } else {\n        arg.slice(1).split('').forEach(function(c) {\n          ret.push('-' + c);\n        });\n      }\n    } else if (/^--/.test(arg) && ~(index = arg.indexOf('='))) {\n      ret.push(arg.slice(0, index), arg.slice(index + 1));\n    } else {\n      ret.push(arg);\n    }\n  }\n\n  return ret;\n};\n\n/**\n * Parse command `args`.\n *\n * When listener(s) are available those\n * callbacks are invoked, otherwise the \"*\"\n * event is emitted and those actions are invoked.\n *\n * @param {Array} args\n * @return {Command} for chaining\n * @api private\n */\n\nCommand.prototype.parseArgs = function(args, unknown) {\n  var name;\n\n  if (args.length) {\n    name = args[0];\n    if (this.listeners('command:' + name).length) {\n      this.emit('command:' + args.shift(), args, unknown);\n    } else {\n      this.emit('command:*', args);\n    }\n  } else {\n    outputHelpIfNecessary(this, unknown);\n\n    // If there were no args and we have unknown options,\n    // then they are extraneous and we need to error.\n    if (unknown.length > 0) {\n      this.unknownOption(unknown[0]);\n    }\n    if (this.commands.length === 0 &&\n        this._args.filter(function(a) { return a.required; }).length === 0) {\n      this.emit('command:*');\n    }\n  }\n\n  return this;\n};\n\n/**\n * Return an option matching `arg` if any.\n *\n * @param {String} arg\n * @return {Option}\n * @api private\n */\n\nCommand.prototype.optionFor = function(arg) {\n  for (var i = 0, len = this.options.length; i < len; ++i) {\n    if (this.options[i].is(arg)) {\n      return this.options[i];\n    }\n  }\n};\n\n/**\n * Parse options from `argv` returning `argv`\n * void of these options.\n *\n * @param {Array} argv\n * @return {Array}\n * @api public\n */\n\nCommand.prototype.parseOptions = function(argv) {\n  var args = [],\n    len = argv.length,\n    literal,\n    option,\n    arg;\n\n  var unknownOptions = [];\n\n  // parse options\n  for (var i = 0; i < len; ++i) {\n    arg = argv[i];\n\n    // literal args after --\n    if (literal) {\n      args.push(arg);\n      continue;\n    }\n\n    if (arg === '--') {\n      literal = true;\n      continue;\n    }\n\n    // find matching Option\n    option = this.optionFor(arg);\n\n    // option is defined\n    if (option) {\n      // requires arg\n      if (option.required) {\n        arg = argv[++i];\n        if (arg == null) return this.optionMissingArgument(option);\n        this.emit('option:' + option.name(), arg);\n      // optional arg\n      } else if (option.optional) {\n        arg = argv[i + 1];\n        if (arg == null || (arg[0] === '-' && arg !== '-')) {\n          arg = null;\n        } else {\n          ++i;\n        }\n        this.emit('option:' + option.name(), arg);\n      // flag\n      } else {\n        this.emit('option:' + option.name());\n      }\n      continue;\n    }\n\n    // looks like an option\n    if (arg.length > 1 && arg[0] === '-') {\n      unknownOptions.push(arg);\n\n      // If the next argument looks like it might be\n      // an argument for this option, we pass it on.\n      // If it isn't, then it'll simply be ignored\n      if ((i + 1) < argv.length && (argv[i + 1][0] !== '-' || argv[i + 1] === '-')) {\n        unknownOptions.push(argv[++i]);\n      }\n      continue;\n    }\n\n    // arg\n    args.push(arg);\n  }\n\n  return { args: args, unknown: unknownOptions };\n};\n\n/**\n * Return an object containing options as key-value pairs\n *\n * @return {Object}\n * @api public\n */\nCommand.prototype.opts = function() {\n  var result = {},\n    len = this.options.length;\n\n  for (var i = 0; i < len; i++) {\n    var key = this.options[i].attributeName();\n    result[key] = key === this._versionOptionName ? this._version : this[key];\n  }\n  return result;\n};\n\n/**\n * Argument `name` is missing.\n *\n * @param {String} name\n * @api private\n */\n\nCommand.prototype.missingArgument = function(name) {\n  console.error(\"error: missing required argument '%s'\", name);\n  process.exit(1);\n};\n\n/**\n * `Option` is missing an argument, but received `flag` or nothing.\n *\n * @param {String} option\n * @param {String} flag\n * @api private\n */\n\nCommand.prototype.optionMissingArgument = function(option, flag) {\n  if (flag) {\n    console.error(\"error: option '%s' argument missing, got '%s'\", option.flags, flag);\n  } else {\n    console.error(\"error: option '%s' argument missing\", option.flags);\n  }\n  process.exit(1);\n};\n\n/**\n * Unknown option `flag`.\n *\n * @param {String} flag\n * @api private\n */\n\nCommand.prototype.unknownOption = function(flag) {\n  if (this._allowUnknownOption) return;\n  console.error(\"error: unknown option '%s'\", flag);\n  process.exit(1);\n};\n\n/**\n * Variadic argument with `name` is not the last argument as required.\n *\n * @param {String} name\n * @api private\n */\n\nCommand.prototype.variadicArgNotLast = function(name) {\n  console.error(\"error: variadic arguments must be last '%s'\", name);\n  process.exit(1);\n};\n\n/**\n * Set the program version to `str`.\n *\n * This method auto-registers the \"-V, --version\" flag\n * which will print the version number when passed.\n *\n * You can optionally supply the  flags and description to override the defaults.\n *\n * @param {String} str\n * @param {String} [flags]\n * @param {String} [description]\n * @return {Command} for chaining\n * @api public\n */\n\nCommand.prototype.version = function(str, flags, description) {\n  if (arguments.length === 0) return this._version;\n  this._version = str;\n  flags = flags || '-V, --version';\n  description = description || 'output the version number';\n  var versionOption = new Option(flags, description);\n  this._versionOptionName = versionOption.long.substr(2) || 'version';\n  this.options.push(versionOption);\n  this.on('option:' + this._versionOptionName, function() {\n    process.stdout.write(str + '\\n');\n    process.exit(0);\n  });\n  return this;\n};\n\n/**\n * Set the description to `str`.\n *\n * @param {String} str\n * @param {Object} argsDescription\n * @return {String|Command}\n * @api public\n */\n\nCommand.prototype.description = function(str, argsDescription) {\n  if (arguments.length === 0) return this._description;\n  this._description = str;\n  this._argsDescription = argsDescription;\n  return this;\n};\n\n/**\n * Set an alias for the command\n *\n * @param {String} alias\n * @return {String|Command}\n * @api public\n */\n\nCommand.prototype.alias = function(alias) {\n  var command = this;\n  if (this.commands.length !== 0) {\n    command = this.commands[this.commands.length - 1];\n  }\n\n  if (arguments.length === 0) return command._alias;\n\n  if (alias === command._name) throw new Error('Command alias can\\'t be the same as its name');\n\n  command._alias = alias;\n  return this;\n};\n\n/**\n * Set / get the command usage `str`.\n *\n * @param {String} str\n * @return {String|Command}\n * @api public\n */\n\nCommand.prototype.usage = function(str) {\n  var args = this._args.map(function(arg) {\n    return humanReadableArgName(arg);\n  });\n\n  var usage = '[options]' +\n    (this.commands.length ? ' [command]' : '') +\n    (this._args.length ? ' ' + args.join(' ') : '');\n\n  if (arguments.length === 0) return this._usage || usage;\n  this._usage = str;\n\n  return this;\n};\n\n/**\n * Get or set the name of the command\n *\n * @param {String} str\n * @return {String|Command}\n * @api public\n */\n\nCommand.prototype.name = function(str) {\n  if (arguments.length === 0) return this._name;\n  this._name = str;\n  return this;\n};\n\n/**\n * Return prepared commands.\n *\n * @return {Array}\n * @api private\n */\n\nCommand.prototype.prepareCommands = function() {\n  return this.commands.filter(function(cmd) {\n    return !cmd._noHelp;\n  }).map(function(cmd) {\n    var args = cmd._args.map(function(arg) {\n      return humanReadableArgName(arg);\n    }).join(' ');\n\n    return [\n      cmd._name +\n        (cmd._alias ? '|' + cmd._alias : '') +\n        (cmd.options.length ? ' [options]' : '') +\n        (args ? ' ' + args : ''),\n      cmd._description\n    ];\n  });\n};\n\n/**\n * Return the largest command length.\n *\n * @return {Number}\n * @api private\n */\n\nCommand.prototype.largestCommandLength = function() {\n  var commands = this.prepareCommands();\n  return commands.reduce(function(max, command) {\n    return Math.max(max, command[0].length);\n  }, 0);\n};\n\n/**\n * Return the largest option length.\n *\n * @return {Number}\n * @api private\n */\n\nCommand.prototype.largestOptionLength = function() {\n  var options = [].slice.call(this.options);\n  options.push({\n    flags: this._helpFlags\n  });\n\n  return options.reduce(function(max, option) {\n    return Math.max(max, option.flags.length);\n  }, 0);\n};\n\n/**\n * Return the largest arg length.\n *\n * @return {Number}\n * @api private\n */\n\nCommand.prototype.largestArgLength = function() {\n  return this._args.reduce(function(max, arg) {\n    return Math.max(max, arg.name.length);\n  }, 0);\n};\n\n/**\n * Return the pad width.\n *\n * @return {Number}\n * @api private\n */\n\nCommand.prototype.padWidth = function() {\n  var width = this.largestOptionLength();\n  if (this._argsDescription && this._args.length) {\n    if (this.largestArgLength() > width) {\n      width = this.largestArgLength();\n    }\n  }\n\n  if (this.commands && this.commands.length) {\n    if (this.largestCommandLength() > width) {\n      width = this.largestCommandLength();\n    }\n  }\n\n  return width;\n};\n\n/**\n * Return help for options.\n *\n * @return {String}\n * @api private\n */\n\nCommand.prototype.optionHelp = function() {\n  var width = this.padWidth();\n\n  // Append the help information\n  return this.options.map(function(option) {\n    return pad(option.flags, width) + '  ' + option.description +\n      ((!option.negate && option.defaultValue !== undefined) ? ' (default: ' + JSON.stringify(option.defaultValue) + ')' : '');\n  }).concat([pad(this._helpFlags, width) + '  ' + this._helpDescription])\n    .join('\\n');\n};\n\n/**\n * Return command help documentation.\n *\n * @return {String}\n * @api private\n */\n\nCommand.prototype.commandHelp = function() {\n  if (!this.commands.length) return '';\n\n  var commands = this.prepareCommands();\n  var width = this.padWidth();\n\n  return [\n    'Commands:',\n    commands.map(function(cmd) {\n      var desc = cmd[1] ? '  ' + cmd[1] : '';\n      return (desc ? pad(cmd[0], width) : cmd[0]) + desc;\n    }).join('\\n').replace(/^/gm, '  '),\n    ''\n  ].join('\\n');\n};\n\n/**\n * Return program help documentation.\n *\n * @return {String}\n * @api private\n */\n\nCommand.prototype.helpInformation = function() {\n  var desc = [];\n  if (this._description) {\n    desc = [\n      this._description,\n      ''\n    ];\n\n    var argsDescription = this._argsDescription;\n    if (argsDescription && this._args.length) {\n      var width = this.padWidth();\n      desc.push('Arguments:');\n      desc.push('');\n      this._args.forEach(function(arg) {\n        desc.push('  ' + pad(arg.name, width) + '  ' + argsDescription[arg.name]);\n      });\n      desc.push('');\n    }\n  }\n\n  var cmdName = this._name;\n  if (this._alias) {\n    cmdName = cmdName + '|' + this._alias;\n  }\n  var parentCmdNames = '';\n  for (var parentCmd = this.parent; parentCmd; parentCmd = parentCmd.parent) {\n    parentCmdNames = parentCmd.name() + ' ' + parentCmdNames;\n  }\n  var usage = [\n    'Usage: ' + parentCmdNames + cmdName + ' ' + this.usage(),\n    ''\n  ];\n\n  var cmds = [];\n  var commandHelp = this.commandHelp();\n  if (commandHelp) cmds = [commandHelp];\n\n  var options = [\n    'Options:',\n    '' + this.optionHelp().replace(/^/gm, '  '),\n    ''\n  ];\n\n  return usage\n    .concat(desc)\n    .concat(options)\n    .concat(cmds)\n    .join('\\n');\n};\n\n/**\n * Output help information for this command.\n *\n * When listener(s) are available for the helpLongFlag\n * those callbacks are invoked.\n *\n * @api public\n */\n\nCommand.prototype.outputHelp = function(cb) {\n  if (!cb) {\n    cb = function(passthru) {\n      return passthru;\n    };\n  }\n  const cbOutput = cb(this.helpInformation());\n  if (typeof cbOutput !== 'string' && !Buffer.isBuffer(cbOutput)) {\n    throw new Error('outputHelp callback must return a string or a Buffer');\n  }\n  process.stdout.write(cbOutput);\n  this.emit(this._helpLongFlag);\n};\n\n/**\n * You can pass in flags and a description to override the help\n * flags and help description for your command.\n *\n * @param {String} [flags]\n * @param {String} [description]\n * @return {Command}\n * @api public\n */\n\nCommand.prototype.helpOption = function(flags, description) {\n  this._helpFlags = flags || this._helpFlags;\n  this._helpDescription = description || this._helpDescription;\n\n  var splitFlags = this._helpFlags.split(/[ ,|]+/);\n\n  if (splitFlags.length > 1) this._helpShortFlag = splitFlags.shift();\n\n  this._helpLongFlag = splitFlags.shift();\n\n  return this;\n};\n\n/**\n * Output help information and exit.\n *\n * @param {Function} [cb]\n * @api public\n */\n\nCommand.prototype.help = function(cb) {\n  this.outputHelp(cb);\n  process.exit();\n};\n\n/**\n * Camel-case the given `flag`\n *\n * @param {String} flag\n * @return {String}\n * @api private\n */\n\nfunction camelcase(flag) {\n  return flag.split('-').reduce(function(str, word) {\n    return str + word[0].toUpperCase() + word.slice(1);\n  });\n}\n\n/**\n * Pad `str` to `width`.\n *\n * @param {String} str\n * @param {Number} width\n * @return {String}\n * @api private\n */\n\nfunction pad(str, width) {\n  var len = Math.max(0, width - str.length);\n  return str + Array(len + 1).join(' ');\n}\n\n/**\n * Output help information if necessary\n *\n * @param {Command} command to output help for\n * @param {Array} array of options to search for -h or --help\n * @api private\n */\n\nfunction outputHelpIfNecessary(cmd, options) {\n  options = options || [];\n\n  for (var i = 0; i < options.length; i++) {\n    if (options[i] === cmd._helpLongFlag || options[i] === cmd._helpShortFlag) {\n      cmd.outputHelp();\n      process.exit(0);\n    }\n  }\n}\n\n/**\n * Takes an argument and returns its human readable equivalent for help usage.\n *\n * @param {Object} arg\n * @return {String}\n * @api private\n */\n\nfunction humanReadableArgName(arg) {\n  var nameOutput = arg.name + (arg.variadic === true ? '...' : '');\n\n  return arg.required\n    ? '<' + nameOutput + '>'\n    : '[' + nameOutput + ']';\n}\n\n// for versions before node v0.8 when there weren't `fs.existsSync`\nfunction exists(file) {\n  try {\n    if (fs.statSync(file).isFile()) {\n      return true;\n    }\n  } catch (e) {\n    return false;\n  }\n}\n\n/**\n * Scan arguments and increment port number for inspect calls (to avoid conflicts when spawning new command).\n *\n * @param {string[]} args - array of arguments from node.execArgv\n * @returns {string[]}\n * @api private\n */\n\nfunction incrementNodeInspectorPort(args) {\n  // Testing for these options:\n  //  --inspect[=[host:]port]\n  //  --inspect-brk[=[host:]port]\n  //  --inspect-port=[host:]port\n  return args.map((arg) => {\n    var result = arg;\n    if (arg.indexOf('--inspect') === 0) {\n      var debugOption;\n      var debugHost = '127.0.0.1';\n      var debugPort = '9229';\n      var match;\n      if ((match = arg.match(/^(--inspect(-brk)?)$/)) !== null) {\n        // e.g. --inspect\n        debugOption = match[1];\n      } else if ((match = arg.match(/^(--inspect(-brk|-port)?)=([^:]+)$/)) !== null) {\n        debugOption = match[1];\n        if (/^\\d+$/.test(match[3])) {\n          // e.g. --inspect=1234\n          debugPort = match[3];\n        } else {\n          // e.g. --inspect=localhost\n          debugHost = match[3];\n        }\n      } else if ((match = arg.match(/^(--inspect(-brk|-port)?)=([^:]+):(\\d+)$/)) !== null) {\n        // e.g. --inspect=localhost:1234\n        debugOption = match[1];\n        debugHost = match[3];\n        debugPort = match[4];\n      }\n\n      if (debugOption && debugPort !== '0') {\n        result = `${debugOption}=${debugHost}:${parseInt(debugPort) + 1}`;\n      }\n    }\n    return result;\n  });\n}\n\n\n//# sourceURL=webpack:///./node_modules/commander/index.js?");

/***/ }),

/***/ "child_process":
/*!********************************!*\
  !*** external "child_process" ***!
  \********************************/
/*! no static exports found */
/***/ (function(module, exports) {

eval("module.exports = require(\"child_process\");\n\n//# sourceURL=webpack:///external_%22child_process%22?");

/***/ }),

/***/ "events":
/*!*************************!*\
  !*** external "events" ***!
  \*************************/
/*! no static exports found */
/***/ (function(module, exports) {

eval("module.exports = require(\"events\");\n\n//# sourceURL=webpack:///external_%22events%22?");

/***/ }),

/***/ "fs":
/*!*********************!*\
  !*** external "fs" ***!
  \*********************/
/*! no static exports found */
/***/ (function(module, exports) {

eval("module.exports = require(\"fs\");\n\n//# sourceURL=webpack:///external_%22fs%22?");

/***/ }),

/***/ "path":
/*!***********************!*\
  !*** external "path" ***!
  \***********************/
/*! no static exports found */
/***/ (function(module, exports) {

eval("module.exports = require(\"path\");\n\n//# sourceURL=webpack:///external_%22path%22?");

/***/ }),

/***/ "util":
/*!***********************!*\
  !*** external "util" ***!
  \***********************/
/*! no static exports found */
/***/ (function(module, exports) {

eval("module.exports = require(\"util\");\n\n//# sourceURL=webpack:///external_%22util%22?");

/***/ })

/******/ });