aboutsummaryrefslogtreecommitdiff
path: root/node_modules/yargs
diff options
context:
space:
mode:
authorFlorian Dold <florian.dold@gmail.com>2017-12-10 21:51:33 +0100
committerFlorian Dold <florian.dold@gmail.com>2017-12-10 21:51:33 +0100
commit0469abd4a9c9270a1fdc962969e36e63699af8b4 (patch)
treef9864d4a4148621378958794cbbfdc2393733283 /node_modules/yargs
parent6947e79bbc258f7bc96af424ddb71a511f0c15a3 (diff)
downloadwallet-core-0469abd4a9c9270a1fdc962969e36e63699af8b4.tar.xz
upgrade dependencies
Diffstat (limited to 'node_modules/yargs')
-rw-r--r--node_modules/yargs/CHANGELOG.md112
-rw-r--r--node_modules/yargs/README.md29
-rw-r--r--node_modules/yargs/completion.sh.hbs4
-rw-r--r--node_modules/yargs/index.js3
-rw-r--r--node_modules/yargs/lib/apply-extends.js21
-rw-r--r--node_modules/yargs/lib/argsert.js30
-rw-r--r--node_modules/yargs/lib/assign.js15
-rw-r--r--node_modules/yargs/lib/command.js309
-rw-r--r--node_modules/yargs/lib/completion.js51
-rw-r--r--node_modules/yargs/lib/levenshtein.js10
-rw-r--r--node_modules/yargs/lib/obj-filter.js7
-rw-r--r--node_modules/yargs/lib/usage.js299
-rw-r--r--node_modules/yargs/lib/validation.js239
-rw-r--r--node_modules/yargs/lib/yerror.js1
-rw-r--r--node_modules/yargs/locales/en.json4
-rw-r--r--node_modules/yargs/locales/hi.json5
-rw-r--r--node_modules/yargs/locales/id.json5
-rw-r--r--node_modules/yargs/locales/ja.json5
-rw-r--r--node_modules/yargs/locales/ko.json5
-rw-r--r--node_modules/yargs/locales/nl.json5
-rw-r--r--node_modules/yargs/locales/pl.json5
-rw-r--r--node_modules/yargs/locales/pt_BR.json6
-rw-r--r--node_modules/yargs/locales/tr.json4
-rw-r--r--node_modules/yargs/node_modules/path-type/index.js26
-rw-r--r--node_modules/yargs/node_modules/path-type/license21
-rw-r--r--node_modules/yargs/node_modules/path-type/package.json48
-rw-r--r--node_modules/yargs/node_modules/path-type/readme.md42
-rw-r--r--node_modules/yargs/node_modules/read-pkg-up/index.js26
-rw-r--r--node_modules/yargs/node_modules/read-pkg-up/license21
-rw-r--r--node_modules/yargs/node_modules/read-pkg-up/package.json62
-rw-r--r--node_modules/yargs/node_modules/read-pkg-up/readme.md80
-rw-r--r--node_modules/yargs/node_modules/read-pkg/index.js47
-rw-r--r--node_modules/yargs/node_modules/read-pkg/license21
-rw-r--r--node_modules/yargs/node_modules/read-pkg/package.json45
-rw-r--r--node_modules/yargs/node_modules/read-pkg/readme.md79
-rw-r--r--node_modules/yargs/node_modules/yargs-parser/CHANGELOG.md223
-rw-r--r--node_modules/yargs/node_modules/yargs-parser/LICENSE.txt14
-rw-r--r--node_modules/yargs/node_modules/yargs-parser/README.md281
-rw-r--r--node_modules/yargs/node_modules/yargs-parser/index.js764
-rw-r--r--node_modules/yargs/node_modules/yargs-parser/lib/tokenize-arg-string.js34
-rw-r--r--node_modules/yargs/node_modules/yargs-parser/package.json43
-rw-r--r--node_modules/yargs/package.json13
-rw-r--r--node_modules/yargs/yargs.js476
43 files changed, 969 insertions, 2571 deletions
diff --git a/node_modules/yargs/CHANGELOG.md b/node_modules/yargs/CHANGELOG.md
index 95f414125..8bb58c3f3 100644
--- a/node_modules/yargs/CHANGELOG.md
+++ b/node_modules/yargs/CHANGELOG.md
@@ -2,6 +2,118 @@
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
+<a name="10.0.3"></a>
+## [10.0.3](https://github.com/yargs/yargs/compare/v10.0.2...v10.0.3) (2017-10-21)
+
+
+### Bug Fixes
+
+* parse array rather than string, so that quotes are safe ([#993](https://github.com/yargs/yargs/issues/993)) ([c351685](https://github.com/yargs/yargs/commit/c351685))
+
+
+
+<a name="10.0.2"></a>
+## [10.0.2](https://github.com/yargs/yargs/compare/v10.0.1...v10.0.2) (2017-10-21)
+
+
+### Bug Fixes
+
+* fix tiny spacing issue with usage ([#992](https://github.com/yargs/yargs/issues/992)) ([7871327](https://github.com/yargs/yargs/commit/7871327))
+
+
+
+<a name="10.0.1"></a>
+## [10.0.1](https://github.com/yargs/yargs/compare/v10.0.0...v10.0.1) (2017-10-19)
+
+
+### Bug Fixes
+
+* help strings for nested commands were missing parent commands ([#990](https://github.com/yargs/yargs/issues/990)) ([cd1ca15](https://github.com/yargs/yargs/commit/cd1ca15))
+* use correct completion command in generated completion script ([#988](https://github.com/yargs/yargs/issues/988)) ([3c8ac1d](https://github.com/yargs/yargs/commit/3c8ac1d))
+
+
+
+<a name="10.0.0"></a>
+# [10.0.0](https://github.com/yargs/yargs/compare/v9.1.0...v10.0.0) (2017-10-18)
+
+
+### Bug Fixes
+
+* config and normalize can be disabled with false ([#952](https://github.com/yargs/yargs/issues/952)) ([3bb8771](https://github.com/yargs/yargs/commit/3bb8771))
+* less eager help command execution ([#972](https://github.com/yargs/yargs/issues/972)) ([8c1d7bf](https://github.com/yargs/yargs/commit/8c1d7bf))
+* the positional argument parse was clobbering global flag arguments ([#984](https://github.com/yargs/yargs/issues/984)) ([7e58453](https://github.com/yargs/yargs/commit/7e58453))
+
+
+### Features
+
+* .usage() can now be used to configure a default command ([#975](https://github.com/yargs/yargs/issues/975)) ([7269531](https://github.com/yargs/yargs/commit/7269531))
+* hidden options are now explicitly indicated using "hidden" flag ([#962](https://github.com/yargs/yargs/issues/962)) ([280d0d6](https://github.com/yargs/yargs/commit/280d0d6))
+* introduce .positional() for configuring positional arguments ([#967](https://github.com/yargs/yargs/issues/967)) ([cb16460](https://github.com/yargs/yargs/commit/cb16460))
+* replace $0 with file basename ([#983](https://github.com/yargs/yargs/issues/983)) ([20bb99b](https://github.com/yargs/yargs/commit/20bb99b))
+
+
+### BREAKING CHANGES
+
+* .usage() no longer accepts an options object as the second argument. It can instead be used as an alias for configuring a default command.
+* previously hidden options were simply implied using a falsy description
+* help command now only executes if it's the last positional in argv._
+
+
+
+<a name="9.1.0"></a>
+# [9.1.0](https://github.com/yargs/yargs/compare/v9.0.1...v9.1.0) (2017-09-25)
+
+
+### Bug Fixes
+
+* **command:** Run default cmd even if the only cmd ([#950](https://github.com/yargs/yargs/issues/950)) ([7b22203](https://github.com/yargs/yargs/commit/7b22203))
+
+
+### Features
+
+* multiple usage calls are now collected, not replaced ([#958](https://github.com/yargs/yargs/issues/958)) ([74a38b2](https://github.com/yargs/yargs/commit/74a38b2))
+
+
+
+<a name="9.0.1"></a>
+## [9.0.1](https://github.com/yargs/yargs/compare/v9.0.0...v9.0.1) (2017-09-17)
+
+
+### Bug Fixes
+
+* implications fails only displayed once ([#954](https://github.com/yargs/yargs/issues/954)) ([ac8088b](https://github.com/yargs/yargs/commit/ac8088b))
+
+
+
+<a name="9.0.0"></a>
+# [9.0.0](https://github.com/yargs/yargs/compare/v8.0.2...v9.0.0) (2017-09-03)
+
+
+### Bug Fixes
+
+* 'undefined' default value for choices resulted in validation failing ([782b896](https://github.com/yargs/yargs/commit/782b896))
+* address bug with handling of arrays of implications ([c240661](https://github.com/yargs/yargs/commit/c240661))
+* defaulting keys to 'undefined' interfered with conflicting key logic ([a8e0cff](https://github.com/yargs/yargs/commit/a8e0cff))
+* don't bother calling JSON.stringify() on string default values ([#891](https://github.com/yargs/yargs/issues/891)) ([628be21](https://github.com/yargs/yargs/commit/628be21))
+* exclude positional arguments from completion output ([#927](https://github.com/yargs/yargs/issues/927)) ([71c7ec7](https://github.com/yargs/yargs/commit/71c7ec7))
+* strict mode should not fail for hidden options ([#949](https://github.com/yargs/yargs/issues/949)) ([0e0c58d](https://github.com/yargs/yargs/commit/0e0c58d))
+
+
+### Features
+
+* allow implies and conflicts to accept array values ([#922](https://github.com/yargs/yargs/issues/922)) ([abdc7da](https://github.com/yargs/yargs/commit/abdc7da))
+* allow parse with no arguments as alias for yargs.argv ([#944](https://github.com/yargs/yargs/issues/944)) ([a9f03e7](https://github.com/yargs/yargs/commit/a9f03e7))
+* enable .help() and .version() by default ([#912](https://github.com/yargs/yargs/issues/912)) ([1ef44e0](https://github.com/yargs/yargs/commit/1ef44e0))
+* to allow both undefined and nulls, for benefit of TypeScript ([#945](https://github.com/yargs/yargs/issues/945)) ([792564d](https://github.com/yargs/yargs/commit/792564d))
+
+
+### BREAKING CHANGES
+
+* version() and help() are now enabled by default, and show up in help output; the implicit help command can no longer be enabled/disabled independently from the help command itself (which can now be disabled).
+* parse() now behaves as an alias for .argv, unless a parseCallback is provided.
+
+
+
<a name="8.0.2"></a>
## [8.0.2](https://github.com/yargs/yargs/compare/v8.0.1...v8.0.2) (2017-06-12)
diff --git a/node_modules/yargs/README.md b/node_modules/yargs/README.md
index 867118bfe..84f8fea10 100644
--- a/node_modules/yargs/README.md
+++ b/node_modules/yargs/README.md
@@ -1,12 +1,19 @@
# Yargs
+_Yargs is developed on evenings and weekends by
+volunteers. Why not grab them dinner or a drink?_
+
+[![Support via Gratipay](https://cdn.rawgit.com/gratipay/gratipay-badge/2.3.0/dist/gratipay.svg)](https://gratipay.com/yargs/)
+
[![Build Status][travis-image]][travis-url]
[![Coverage Status][coveralls-image]][coveralls-url]
[![NPM version][npm-image]][npm-url]
[![Windows Tests][windows-image]][windows-url]
[![js-standard-style][standard-image]][standard-url]
[![Conventional Commits][conventional-commits-image]][conventional-commits-url]
-[![Gitter][gitter-image]][gitter-url]
+[![Slack][slack-image]][slack-url]
+
+_Having problems? want to contribute? join our [community slack](http://devtoolscommunity.herokuapp.com)_.
> Yargs be a node.js library fer hearties tryin' ter parse optstrings.
@@ -53,12 +60,13 @@ Retreat from the xupptumblers!
```js
#!/usr/bin/env node
-const yargs = require('yargs') // eslint-disable-line
- .command('serve', 'start the server', (yargs) => {
- yargs.option('port', {
- describe: 'port to bind on',
- default: 5000
- })
+require('yargs') // eslint-disable-line
+ .command('serve [port]', 'start the server', (yargs) => {
+ yargs
+ .positional('port', {
+ describe: 'port to bind on',
+ default: 5000
+ })
}, (argv) => {
if (argv.verbose) console.info(`start server on :${argv.port}`)
serve(argv.port)
@@ -67,10 +75,11 @@ const yargs = require('yargs') // eslint-disable-line
alias: 'v',
default: false
})
- .help()
.argv
```
+Run the example above with `--help` to see the help for the application.
+
## Table of Contents
* [Yargs' API](/docs/api.md)
@@ -99,5 +108,5 @@ const yargs = require('yargs') // eslint-disable-line
[standard-url]: http://standardjs.com/
[conventional-commits-image]: https://img.shields.io/badge/Conventional%20Commits-1.0.0-yellow.svg
[conventional-commits-url]: https://conventionalcommits.org/
-[gitter-image]: https://img.shields.io/gitter/room/nwjs/nw.js.svg?maxAge=2592000
-[gitter-url]: https://gitter.im/yargs/Lobby?utm_source=share-link&utm_medium=link&utm_campaign=share-link
+[slack-image]: http://devtoolscommunity.herokuapp.com/badge.svg
+[slack-url]: http://devtoolscommunity.herokuapp.com
diff --git a/node_modules/yargs/completion.sh.hbs b/node_modules/yargs/completion.sh.hbs
index 14445b834..819c8ae83 100644
--- a/node_modules/yargs/completion.sh.hbs
+++ b/node_modules/yargs/completion.sh.hbs
@@ -2,8 +2,8 @@
#
# yargs command completion script
#
-# Installation: {{app_path}} completion >> ~/.bashrc
-# or {{app_path}} completion >> ~/.bash_profile on OSX.
+# Installation: {{app_path}} {{completion_command}} >> ~/.bashrc
+# or {{app_path}} {{completion_command}} >> ~/.bash_profile on OSX.
#
_yargs_completions()
{
diff --git a/node_modules/yargs/index.js b/node_modules/yargs/index.js
index 37450cf7a..dfed54bc5 100644
--- a/node_modules/yargs/index.js
+++ b/node_modules/yargs/index.js
@@ -1,3 +1,4 @@
+'use strict'
// classic singleton yargs API, to use yargs
// without running as a singleton do:
// require('yargs/yargs')(process.argv.slice(2))
@@ -21,7 +22,7 @@ function Argv (processArgs, cwd) {
to get a parsed version of process.argv.
*/
function singletonify (inst) {
- Object.keys(inst).forEach(function (key) {
+ Object.keys(inst).forEach((key) => {
if (key === 'argv') {
Argv.__defineGetter__(key, inst.__lookupGetter__(key))
} else {
diff --git a/node_modules/yargs/lib/apply-extends.js b/node_modules/yargs/lib/apply-extends.js
index 5fc69fab1..3005848e3 100644
--- a/node_modules/yargs/lib/apply-extends.js
+++ b/node_modules/yargs/lib/apply-extends.js
@@ -1,13 +1,14 @@
-var fs = require('fs')
-var path = require('path')
-var assign = require('./assign')
-var YError = require('./yerror')
-var previouslyVisitedConfigs = []
+'use strict'
+const fs = require('fs')
+const path = require('path')
+const YError = require('./yerror')
+
+let previouslyVisitedConfigs = []
function checkForCircularExtends (path) {
if (previouslyVisitedConfigs.indexOf(path) > -1) {
- throw new YError("Circular extended configurations: '" + path + "'.")
+ throw new YError(`Circular extended configurations: '${path}'.`)
}
}
@@ -16,12 +17,12 @@ function getPathToDefaultConfig (cwd, pathToExtend) {
}
function applyExtends (config, cwd) {
- var defaultConfig = {}
+ let defaultConfig = {}
if (config.hasOwnProperty('extends')) {
if (typeof config.extends !== 'string') return defaultConfig
- var isPath = /\.json$/.test(config.extends)
- var pathToDefault = null
+ const isPath = /\.json$/.test(config.extends)
+ let pathToDefault = null
if (!isPath) {
try {
pathToDefault = require.resolve(config.extends)
@@ -46,7 +47,7 @@ function applyExtends (config, cwd) {
previouslyVisitedConfigs = []
- return assign(defaultConfig, config)
+ return Object.assign({}, defaultConfig, config)
}
module.exports = applyExtends
diff --git a/node_modules/yargs/lib/argsert.js b/node_modules/yargs/lib/argsert.js
index d3e72fce5..ed1d59871 100644
--- a/node_modules/yargs/lib/argsert.js
+++ b/node_modules/yargs/lib/argsert.js
@@ -1,20 +1,21 @@
+'use strict'
const command = require('./command')()
const YError = require('./yerror')
const positionName = ['first', 'second', 'third', 'fourth', 'fifth', 'sixth']
-module.exports = function (expected, callerArguments, length) {
+module.exports = function argsert (expected, callerArguments, length) {
// TODO: should this eventually raise an exception.
try {
// preface the argument description with "cmd", so
// that we can run it through yargs' command parser.
- var position = 0
- var parsed = {demanded: [], optional: []}
+ let position = 0
+ let parsed = {demanded: [], optional: []}
if (typeof expected === 'object') {
length = callerArguments
callerArguments = expected
} else {
- parsed = command.parseCommand('cmd ' + expected)
+ parsed = command.parseCommand(`cmd ${expected}`)
}
const args = [].slice.call(callerArguments)
@@ -22,33 +23,27 @@ module.exports = function (expected, callerArguments, length) {
length = length || args.length
if (length < parsed.demanded.length) {
- throw new YError('Not enough arguments provided. Expected ' + parsed.demanded.length +
- ' but received ' + args.length + '.')
+ throw new YError(`Not enough arguments provided. Expected ${parsed.demanded.length} but received ${args.length}.`)
}
const totalCommands = parsed.demanded.length + parsed.optional.length
if (length > totalCommands) {
- throw new YError('Too many arguments provided. Expected max ' + totalCommands +
- ' but received ' + length + '.')
+ throw new YError(`Too many arguments provided. Expected max ${totalCommands} but received ${length}.`)
}
- parsed.demanded.forEach(function (demanded) {
+ parsed.demanded.forEach((demanded) => {
const arg = args.shift()
const observedType = guessType(arg)
- const matchingTypes = demanded.cmd.filter(function (type) {
- return type === observedType || type === '*'
- })
+ const matchingTypes = demanded.cmd.filter(type => type === observedType || type === '*')
if (matchingTypes.length === 0) argumentTypeError(observedType, demanded.cmd, position, false)
position += 1
})
- parsed.optional.forEach(function (optional) {
+ parsed.optional.forEach((optional) => {
if (args.length === 0) return
const arg = args.shift()
const observedType = guessType(arg)
- const matchingTypes = optional.cmd.filter(function (type) {
- return type === observedType || type === '*'
- })
+ const matchingTypes = optional.cmd.filter(type => type === observedType || type === '*')
if (matchingTypes.length === 0) argumentTypeError(observedType, optional.cmd, position, true)
position += 1
})
@@ -67,6 +62,5 @@ function guessType (arg) {
}
function argumentTypeError (observedType, allowedTypes, position, optional) {
- throw new YError('Invalid ' + (positionName[position] || 'manyith') + ' argument.' +
- ' Expected ' + allowedTypes.join(' or ') + ' but received ' + observedType + '.')
+ throw new YError(`Invalid ${positionName[position] || 'manyith'} argument. Expected ${allowedTypes.join(' or ')} but received ${observedType}.`)
}
diff --git a/node_modules/yargs/lib/assign.js b/node_modules/yargs/lib/assign.js
deleted file mode 100644
index 7d5a3cef2..000000000
--- a/node_modules/yargs/lib/assign.js
+++ /dev/null
@@ -1,15 +0,0 @@
-// lazy Object.assign logic that only works for merging
-// two objects; eventually we should replace this with Object.assign.
-module.exports = function assign (defaults, configuration) {
- var o = {}
- configuration = configuration || {}
-
- Object.keys(defaults).forEach(function (k) {
- o[k] = defaults[k]
- })
- Object.keys(configuration).forEach(function (k) {
- o[k] = configuration[k]
- })
-
- return o
-}
diff --git a/node_modules/yargs/lib/command.js b/node_modules/yargs/lib/command.js
index 3567cf953..5ac848e21 100644
--- a/node_modules/yargs/lib/command.js
+++ b/node_modules/yargs/lib/command.js
@@ -1,27 +1,29 @@
-const path = require('path')
+'use strict'
+
const inspect = require('util').inspect
-const camelCase = require('camelcase')
+const path = require('path')
+const Parser = require('yargs-parser')
-const DEFAULT_MARKER = '*'
+const DEFAULT_MARKER = /(^\*)|(^\$0)/
// handles parsing positional arguments,
// and populating argv with said positional
// arguments.
-module.exports = function (yargs, usage, validation) {
+module.exports = function command (yargs, usage, validation) {
const self = {}
- var handlers = {}
- var aliasMap = {}
- var defaultCommand
- self.addHandler = function (cmd, description, builder, handler) {
- var aliases = []
- handler = handler || function () {}
+ let handlers = {}
+ let aliasMap = {}
+ let defaultCommand
+ self.addHandler = function addHandler (cmd, description, builder, handler) {
+ let aliases = []
+ handler = handler || (() => {})
if (Array.isArray(cmd)) {
aliases = cmd.slice(1)
cmd = cmd[0]
} else if (typeof cmd === 'object') {
- var command = (Array.isArray(cmd.command) || typeof cmd.command === 'string') ? cmd.command : moduleName(cmd)
+ let command = (Array.isArray(cmd.command) || typeof cmd.command === 'string') ? cmd.command : moduleName(cmd)
if (cmd.aliases) command = [].concat(command).concat(cmd.aliases)
self.addHandler(command, extractDesc(cmd), cmd.builder, cmd.handler)
return
@@ -34,34 +36,22 @@ module.exports = function (yargs, usage, validation) {
}
// parse positionals out of cmd string
- var parsedCommand = self.parseCommand(cmd)
+ const parsedCommand = self.parseCommand(cmd)
// remove positional args from aliases only
- aliases = aliases.map(function (alias) {
- return self.parseCommand(alias).cmd
- })
+ aliases = aliases.map(alias => self.parseCommand(alias).cmd)
// check for default and filter out '*''
- var isDefault = false
- var parsedAliases = [parsedCommand.cmd].concat(aliases).filter(function (c) {
- if (c === DEFAULT_MARKER) {
+ let isDefault = false
+ const parsedAliases = [parsedCommand.cmd].concat(aliases).filter((c) => {
+ if (DEFAULT_MARKER.test(c)) {
isDefault = true
return false
}
return true
})
-
- // short-circuit if default with no aliases
- if (isDefault && parsedAliases.length === 0) {
- defaultCommand = {
- original: cmd.replace(DEFAULT_MARKER, '').trim(),
- handler: handler,
- builder: builder || {},
- demanded: parsedCommand.demanded,
- optional: parsedCommand.optional
- }
- return
- }
+ // standardize on $0 for default command.
+ if (parsedAliases.length === 0 && isDefault) parsedAliases.push('$0')
// shift cmd and aliases after filtering out '*'
if (isDefault) {
@@ -71,7 +61,7 @@ module.exports = function (yargs, usage, validation) {
}
// populate aliasMap
- aliases.forEach(function (alias) {
+ aliases.forEach((alias) => {
aliasMap[alias] = parsedCommand.cmd
})
@@ -81,7 +71,8 @@ module.exports = function (yargs, usage, validation) {
handlers[parsedCommand.cmd] = {
original: cmd,
- handler: handler,
+ description: description,
+ handler,
builder: builder || {},
demanded: parsedCommand.demanded,
optional: parsedCommand.optional
@@ -90,16 +81,16 @@ module.exports = function (yargs, usage, validation) {
if (isDefault) defaultCommand = handlers[parsedCommand.cmd]
}
- self.addDirectory = function (dir, context, req, callerFile, opts) {
+ self.addDirectory = function addDirectory (dir, context, req, callerFile, opts) {
opts = opts || {}
// disable recursion to support nested directories of subcommands
if (typeof opts.recurse !== 'boolean') opts.recurse = false
// exclude 'json', 'coffee' from require-directory defaults
if (!Array.isArray(opts.extensions)) opts.extensions = ['js']
// allow consumer to define their own visitor function
- const parentVisit = typeof opts.visit === 'function' ? opts.visit : function (o) { return o }
+ const parentVisit = typeof opts.visit === 'function' ? opts.visit : o => o
// call addHandler via visitor function
- opts.visit = function (obj, joined, filename) {
+ opts.visit = function visit (obj, joined, filename) {
const visited = parentVisit(obj, joined, filename)
// allow consumer to skip modules with their own visitor
if (visited) {
@@ -119,7 +110,7 @@ module.exports = function (yargs, usage, validation) {
// if module was not require()d and no name given, throw error
function moduleName (obj) {
const mod = require('which-module')(obj)
- if (!mod) throw new Error('No command name given for module: ' + inspect(obj))
+ if (!mod) throw new Error(`No command name given for module: ${inspect(obj)}`)
return commandFromFilename(mod.filename)
}
@@ -129,66 +120,62 @@ module.exports = function (yargs, usage, validation) {
}
function extractDesc (obj) {
- for (var keys = ['describe', 'description', 'desc'], i = 0, l = keys.length, test; i < l; i++) {
+ for (let keys = ['describe', 'description', 'desc'], i = 0, l = keys.length, test; i < l; i++) {
test = obj[keys[i]]
if (typeof test === 'string' || typeof test === 'boolean') return test
}
return false
}
- self.parseCommand = function (cmd) {
- var extraSpacesStrippedCommand = cmd.replace(/\s{2,}/g, ' ')
- var splitCommand = extraSpacesStrippedCommand.split(/\s+(?![^[]*]|[^<]*>)/)
- var bregex = /\.*[\][<>]/g
- var parsedCommand = {
+ self.parseCommand = function parseCommand (cmd) {
+ const extraSpacesStrippedCommand = cmd.replace(/\s{2,}/g, ' ')
+ const splitCommand = extraSpacesStrippedCommand.split(/\s+(?![^[]*]|[^<]*>)/)
+ const bregex = /\.*[\][<>]/g
+ const parsedCommand = {
cmd: (splitCommand.shift()).replace(bregex, ''),
demanded: [],
optional: []
}
- splitCommand.forEach(function (cmd, i) {
- var variadic = false
+ splitCommand.forEach((cmd, i) => {
+ let variadic = false
cmd = cmd.replace(/\s/g, '')
if (/\.+[\]>]/.test(cmd) && i === splitCommand.length - 1) variadic = true
if (/^\[/.test(cmd)) {
parsedCommand.optional.push({
cmd: cmd.replace(bregex, '').split('|'),
- variadic: variadic
+ variadic
})
} else {
parsedCommand.demanded.push({
cmd: cmd.replace(bregex, '').split('|'),
- variadic: variadic
+ variadic
})
}
})
return parsedCommand
}
- self.getCommands = function () {
- return Object.keys(handlers).concat(Object.keys(aliasMap))
- }
+ self.getCommands = () => Object.keys(handlers).concat(Object.keys(aliasMap))
- self.getCommandHandlers = function () {
- return handlers
- }
+ self.getCommandHandlers = () => handlers
- self.hasDefaultCommand = function () {
- return !!defaultCommand
- }
+ self.hasDefaultCommand = () => !!defaultCommand
- self.runCommand = function (command, yargs, parsed, commandIndex) {
- var aliases = parsed.aliases
- var commandHandler = handlers[command] || handlers[aliasMap[command]] || defaultCommand
- var currentContext = yargs.getContext()
- var numFiles = currentContext.files.length
- var parentCommands = currentContext.commands.slice()
+ self.runCommand = function runCommand (command, yargs, parsed, commandIndex) {
+ let aliases = parsed.aliases
+ const commandHandler = handlers[command] || handlers[aliasMap[command]] || defaultCommand
+ const currentContext = yargs.getContext()
+ let numFiles = currentContext.files.length
+ const parentCommands = currentContext.commands.slice()
// what does yargs look like after the buidler is run?
- var innerArgv = parsed.argv
- var innerYargs = null
- var positionalMap = {}
-
- if (command) currentContext.commands.push(command)
+ let innerArgv = parsed.argv
+ let innerYargs = null
+ let positionalMap = {}
+ if (command) {
+ currentContext.commands.push(command)
+ currentContext.fullCommands.push(commandHandler.original)
+ }
if (typeof commandHandler.builder === 'function') {
// a function can be provided, which builds
// up a yargs chain and possibly returns it.
@@ -198,8 +185,11 @@ module.exports = function (yargs, usage, validation) {
// original command string as usage() for consistent behavior with
// options object below.
if (yargs.parsed === false) {
- if (typeof yargs.getUsageInstance().getUsage() === 'undefined') {
- yargs.usage('$0 ' + (parentCommands.length ? parentCommands.join(' ') + ' ' : '') + commandHandler.original)
+ if (shouldUpdateUsage(yargs)) {
+ yargs.getUsageInstance().usage(
+ usageFromParentCommandsCommandHandler(parentCommands, commandHandler),
+ commandHandler.description
+ )
}
innerArgv = innerYargs ? innerYargs._parseArgs(null, null, true, commandIndex) : yargs._parseArgs(null, null, true, commandIndex)
} else {
@@ -212,8 +202,13 @@ module.exports = function (yargs, usage, validation) {
// as a short hand, an object can instead be provided, specifying
// the options that a command takes.
innerYargs = yargs.reset(parsed.aliases)
- innerYargs.usage('$0 ' + (parentCommands.length ? parentCommands.join(' ') + ' ' : '') + commandHandler.original)
- Object.keys(commandHandler.builder).forEach(function (key) {
+ if (shouldUpdateUsage(innerYargs)) {
+ innerYargs.getUsageInstance().usage(
+ usageFromParentCommandsCommandHandler(parentCommands, commandHandler),
+ commandHandler.description
+ )
+ }
+ Object.keys(commandHandler.builder).forEach((key) => {
innerYargs.option(key, commandHandler.builder[key])
})
innerArgv = innerYargs._parseArgs(null, null, true, commandIndex)
@@ -233,81 +228,163 @@ module.exports = function (yargs, usage, validation) {
commandHandler.handler(innerArgv)
}
- if (command) currentContext.commands.pop()
+ if (command) {
+ currentContext.commands.pop()
+ currentContext.fullCommands.pop()
+ }
numFiles = currentContext.files.length - numFiles
if (numFiles > 0) currentContext.files.splice(numFiles * -1, numFiles)
return innerArgv
}
+ function shouldUpdateUsage (yargs) {
+ return !yargs.getUsageInstance().getUsageDisabled() &&
+ yargs.getUsageInstance().getUsage().length === 0
+ }
+
+ function usageFromParentCommandsCommandHandler (parentCommands, commandHandler) {
+ const c = DEFAULT_MARKER.test(commandHandler.original) ? commandHandler.original.replace(DEFAULT_MARKER, '').trim() : commandHandler.original
+ const pc = parentCommands.filter((c) => { return !DEFAULT_MARKER.test(c) })
+ pc.push(c)
+ return `$0 ${pc.join(' ')}`
+ }
+
+ self.runDefaultBuilderOn = function (yargs) {
+ if (shouldUpdateUsage(yargs)) {
+ // build the root-level command string from the default string.
+ const commandString = DEFAULT_MARKER.test(defaultCommand.original)
+ ? defaultCommand.original : defaultCommand.original.replace(/^[^[\]<>]*/, '$0 ')
+ yargs.getUsageInstance().usage(
+ commandString,
+ defaultCommand.description
+ )
+ }
+ const builder = defaultCommand.builder
+ if (typeof builder === 'function') {
+ builder(yargs)
+ } else {
+ Object.keys(builder).forEach((key) => {
+ yargs.option(key, builder[key])
+ })
+ }
+ }
+
// transcribe all positional arguments "command <foo> <bar> [apple]"
// onto argv.
function populatePositionals (commandHandler, argv, context, yargs) {
argv._ = argv._.slice(context.commands.length) // nuke the current commands
- var demanded = commandHandler.demanded.slice(0)
- var optional = commandHandler.optional.slice(0)
- var positionalMap = {}
+ const demanded = commandHandler.demanded.slice(0)
+ const optional = commandHandler.optional.slice(0)
+ const positionalMap = {}
validation.positionalCount(demanded.length, argv._.length)
while (demanded.length) {
- var demand = demanded.shift()
- populatePositional(demand, argv, yargs, positionalMap)
+ const demand = demanded.shift()
+ populatePositional(demand, argv, positionalMap)
}
while (optional.length) {
- var maybe = optional.shift()
- populatePositional(maybe, argv, yargs, positionalMap)
+ const maybe = optional.shift()
+ populatePositional(maybe, argv, positionalMap)
}
argv._ = context.commands.concat(argv._)
+
+ postProcessPositionals(argv, positionalMap, self.cmdToParseOptions(commandHandler.original))
+
return positionalMap
}
- // populate a single positional argument and its
- // aliases onto argv.
- function populatePositional (positional, argv, yargs, positionalMap) {
- // "positional" consists of the positional.cmd, an array representing
- // the positional's name and aliases, and positional.variadic
- // indicating whether or not it is a variadic array.
- var variadics = null
- var value = null
- for (var i = 0, cmd; (cmd = positional.cmd[i]) !== undefined; i++) {
- if (positional.variadic) {
- if (variadics) argv[cmd] = variadics.slice(0)
- else argv[cmd] = variadics = argv._.splice(0)
- } else {
- if (!value && !argv._.length) continue
- if (value) argv[cmd] = value
- else argv[cmd] = value = argv._.shift()
- }
- positionalMap[cmd] = true
- postProcessPositional(yargs, argv, cmd)
- addCamelCaseExpansions(argv, cmd)
+ function populatePositional (positional, argv, positionalMap, parseOptions) {
+ const cmd = positional.cmd[0]
+ if (positional.variadic) {
+ positionalMap[cmd] = argv._.splice(0).map(String)
+ } else {
+ if (argv._.length) positionalMap[cmd] = [String(argv._.shift())]
}
}
- // TODO move positional arg logic to yargs-parser and remove this duplication
- function postProcessPositional (yargs, argv, key) {
- var coerce = yargs.getOptions().coerce[key]
- if (typeof coerce === 'function') {
- try {
- argv[key] = coerce(argv[key])
- } catch (err) {
- yargs.getUsageInstance().fail(err.message, err)
- }
+ // we run yargs-parser against the positional arguments
+ // applying the same parsing logic used for flags.
+ function postProcessPositionals (argv, positionalMap, parseOptions) {
+ // combine the parsing hints we've inferred from the command
+ // string with explicitly configured parsing hints.
+ const options = Object.assign({}, yargs.getOptions())
+ options.default = Object.assign(parseOptions.default, options.default)
+ options.alias = Object.assign(parseOptions.alias, options.alias)
+ options.array = options.array.concat(parseOptions.array)
+
+ const unparsed = []
+ Object.keys(positionalMap).forEach((key) => {
+ positionalMap[key].map((value) => {
+ unparsed.push(`--${key}`)
+ unparsed.push(value)
+ })
+ })
+
+ // short-circuit parse.
+ if (!unparsed.length) return
+
+ const parsed = Parser.detailed(unparsed, options)
+
+ if (parsed.error) {
+ yargs.getUsageInstance().fail(parsed.error.message, parsed.error)
+ } else {
+ // only copy over positional keys (don't overwrite
+ // flag arguments that were already parsed).
+ const positionalKeys = Object.keys(positionalMap)
+ Object.keys(positionalMap).forEach((key) => {
+ [].push.apply(positionalKeys, parsed.aliases[key])
+ })
+
+ Object.keys(parsed.argv).forEach((key) => {
+ if (positionalKeys.indexOf(key) !== -1) {
+ argv[key] = parsed.argv[key]
+ }
+ })
}
}
- function addCamelCaseExpansions (argv, option) {
- if (/-/.test(option)) {
- const cc = camelCase(option)
- if (typeof argv[option] === 'object') argv[cc] = argv[option].slice(0)
- else argv[cc] = argv[option]
+ self.cmdToParseOptions = function (cmdString) {
+ const parseOptions = {
+ array: [],
+ default: {},
+ alias: {},
+ demand: {}
}
+
+ const parsed = self.parseCommand(cmdString)
+ parsed.demanded.forEach((d) => {
+ const cmds = d.cmd.slice(0)
+ const cmd = cmds.shift()
+ if (d.variadic) {
+ parseOptions.array.push(cmd)
+ parseOptions.default[cmd] = []
+ }
+ cmds.forEach((c) => {
+ parseOptions.alias[cmd] = c
+ })
+ parseOptions.demand[cmd] = true
+ })
+
+ parsed.optional.forEach((o) => {
+ const cmds = o.cmd.slice(0)
+ const cmd = cmds.shift()
+ if (o.variadic) {
+ parseOptions.array.push(cmd)
+ parseOptions.default[cmd] = []
+ }
+ cmds.forEach((c) => {
+ parseOptions.alias[cmd] = c
+ })
+ })
+
+ return parseOptions
}
- self.reset = function () {
+ self.reset = () => {
handlers = {}
aliasMap = {}
defaultCommand = undefined
@@ -318,14 +395,14 @@ module.exports = function (yargs, usage, validation) {
// the state of commands such that
// we can apply .parse() multiple times
// with the same yargs instance.
- var frozen
- self.freeze = function () {
+ let frozen
+ self.freeze = () => {
frozen = {}
frozen.handlers = handlers
frozen.aliasMap = aliasMap
frozen.defaultCommand = defaultCommand
}
- self.unfreeze = function () {
+ self.unfreeze = () => {
handlers = frozen.handlers
aliasMap = frozen.aliasMap
defaultCommand = frozen.defaultCommand
diff --git a/node_modules/yargs/lib/completion.js b/node_modules/yargs/lib/completion.js
index 5cd9a18a0..ad6969a2d 100644
--- a/node_modules/yargs/lib/completion.js
+++ b/node_modules/yargs/lib/completion.js
@@ -1,16 +1,17 @@
+'use strict'
const fs = require('fs')
const path = require('path')
// add bash completions to your
// yargs-powered applications.
-module.exports = function (yargs, usage, command) {
+module.exports = function completion (yargs, usage, command) {
const self = {
completionKey: 'get-yargs-completions'
}
// get a list of completion commands.
// 'args' is the array of strings from the line to be completed
- self.getCompletion = function (args, done) {
+ self.getCompletion = function getCompletion (args, done) {
const completions = []
const current = args.length ? args[args.length - 1] : ''
const argv = yargs.parse(args, true)
@@ -20,14 +21,14 @@ module.exports = function (yargs, usage, command) {
// to completion().
if (completionFunction) {
if (completionFunction.length < 3) {
- var result = completionFunction(current, argv)
+ const result = completionFunction(current, argv)
// promise based completion function.
if (typeof result.then === 'function') {
- return result.then(function (list) {
- process.nextTick(function () { done(list) })
- }).catch(function (err) {
- process.nextTick(function () { throw err })
+ return result.then((list) => {
+ process.nextTick(() => { done(list) })
+ }).catch((err) => {
+ process.nextTick(() => { throw err })
})
}
@@ -35,14 +36,14 @@ module.exports = function (yargs, usage, command) {
return done(result)
} else {
// asynchronous completion function
- return completionFunction(current, argv, function (completions) {
+ return completionFunction(current, argv, (completions) => {
done(completions)
})
}
}
- var handlers = command.getCommandHandlers()
- for (var i = 0, ii = args.length; i < ii; ++i) {
+ const handlers = command.getCommandHandlers()
+ for (let i = 0, ii = args.length; i < ii; ++i) {
if (handlers[args[i]] && handlers[args[i]].builder) {
const builder = handlers[args[i]].builder
if (typeof builder === 'function') {
@@ -54,22 +55,21 @@ module.exports = function (yargs, usage, command) {
}
if (!current.match(/^-/)) {
- usage.getCommands().forEach(function (command) {
- if (args.indexOf(command[0]) === -1) {
- completions.push(command[0])
+ usage.getCommands().forEach((usageCommand) => {
+ const commandName = command.parseCommand(usageCommand[0]).cmd
+ if (args.indexOf(commandName) === -1) {
+ completions.push(commandName)
}
})
}
if (current.match(/^-/)) {
- Object.keys(yargs.getOptions().key).forEach(function (key) {
+ Object.keys(yargs.getOptions().key).forEach((key) => {
// If the key and its aliases aren't in 'args', add the key to 'completions'
- var keyAndAliases = [key].concat(aliases[key] || [])
- var notInArgs = keyAndAliases.every(function (val) {
- return args.indexOf('--' + val) === -1
- })
+ const keyAndAliases = [key].concat(aliases[key] || [])
+ const notInArgs = keyAndAliases.every(val => args.indexOf(`--${val}`) === -1)
if (notInArgs) {
- completions.push('--' + key)
+ completions.push(`--${key}`)
}
})
}
@@ -78,25 +78,26 @@ module.exports = function (yargs, usage, command) {
}
// generate the completion script to add to your .bashrc.
- self.generateCompletionScript = function ($0) {
- var script = fs.readFileSync(
+ self.generateCompletionScript = function generateCompletionScript ($0, cmd) {
+ let script = fs.readFileSync(
path.resolve(__dirname, '../completion.sh.hbs'),
'utf-8'
)
- var name = path.basename($0)
+ const name = path.basename($0)
// add ./to applications not yet installed as bin.
- if ($0.match(/\.js$/)) $0 = './' + $0
+ if ($0.match(/\.js$/)) $0 = `./${$0}`
script = script.replace(/{{app_name}}/g, name)
+ script = script.replace(/{{completion_command}}/g, cmd)
return script.replace(/{{app_path}}/g, $0)
}
// register a function to perform your own custom
// completions., this function can be either
// synchrnous or asynchronous.
- var completionFunction = null
- self.registerFunction = function (fn) {
+ let completionFunction = null
+ self.registerFunction = (fn) => {
completionFunction = fn
}
diff --git a/node_modules/yargs/lib/levenshtein.js b/node_modules/yargs/lib/levenshtein.js
index 6ec216f59..f32b0c277 100644
--- a/node_modules/yargs/lib/levenshtein.js
+++ b/node_modules/yargs/lib/levenshtein.js
@@ -10,22 +10,22 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
// levenshtein distance algorithm, pulled from Andrei Mackenzie's MIT licensed.
// gist, which can be found here: https://gist.github.com/andrei-m/982927
-
+'use strict'
// Compute the edit distance between the two given strings
-module.exports = function (a, b) {
+module.exports = function levenshtein (a, b) {
if (a.length === 0) return b.length
if (b.length === 0) return a.length
- var matrix = []
+ const matrix = []
// increment along the first column of each row
- var i
+ let i
for (i = 0; i <= b.length; i++) {
matrix[i] = [i]
}
// increment each column in the first row
- var j
+ let j
for (j = 0; j <= a.length; j++) {
matrix[0][j] = j
}
diff --git a/node_modules/yargs/lib/obj-filter.js b/node_modules/yargs/lib/obj-filter.js
index 42cb9961e..c344ac58c 100644
--- a/node_modules/yargs/lib/obj-filter.js
+++ b/node_modules/yargs/lib/obj-filter.js
@@ -1,7 +1,8 @@
-module.exports = function (original, filter) {
+'use strict'
+module.exports = function objFilter (original, filter) {
const obj = {}
- filter = filter || function (k, v) { return true }
- Object.keys(original || {}).forEach(function (key) {
+ filter = filter || ((k, v) => true)
+ Object.keys(original || {}).forEach((key) => {
if (filter(key, original[key])) {
obj[key] = original[key]
}
diff --git a/node_modules/yargs/lib/usage.js b/node_modules/yargs/lib/usage.js
index 43f71225c..cf79b10de 100644
--- a/node_modules/yargs/lib/usage.js
+++ b/node_modules/yargs/lib/usage.js
@@ -1,23 +1,25 @@
+'use strict'
// this file handles outputting usage instructions,
// failures, etc. keeps logging in one place.
const stringWidth = require('string-width')
const objFilter = require('./obj-filter')
+const path = require('path')
const setBlocking = require('set-blocking')
const YError = require('./yerror')
-module.exports = function (yargs, y18n) {
+module.exports = function usage (yargs, y18n) {
const __ = y18n.__
const self = {}
// methods for ouputting/building failure message.
- var fails = []
- self.failFn = function (f) {
+ const fails = []
+ self.failFn = function failFn (f) {
fails.push(f)
}
- var failMessage = null
- var showHelpOnFail = true
- self.showHelpOnFail = function (enabled, message) {
+ let failMessage = null
+ let showHelpOnFail = true
+ self.showHelpOnFail = function showHelpOnFailFn (enabled, message) {
if (typeof enabled === 'string') {
message = enabled
enabled = true
@@ -29,12 +31,12 @@ module.exports = function (yargs, y18n) {
return self
}
- var failureOutput = false
- self.fail = function (msg, err) {
+ let failureOutput = false
+ self.fail = function fail (msg, err) {
const logger = yargs._getLoggerInstance()
if (fails.length) {
- for (var i = fails.length - 1; i >= 0; --i) {
+ for (let i = fails.length - 1; i >= 0; --i) {
fails[i](msg, err, self)
}
} else {
@@ -63,56 +65,67 @@ module.exports = function (yargs, y18n) {
}
// methods for ouputting/building help (usage) message.
- var usage
- self.usage = function (msg) {
- usage = msg
+ let usages = []
+ let usageDisabled = false
+ self.usage = (msg, description) => {
+ if (msg === null) {
+ usageDisabled = true
+ usages = []
+ return
+ }
+ usageDisabled = false
+ usages.push([msg, description || ''])
+ return self
+ }
+ self.getUsage = () => {
+ return usages
}
- self.getUsage = function () {
- return usage
+ self.getUsageDisabled = () => {
+ return usageDisabled
+ }
+
+ self.getPositionalGroupName = () => {
+ return __('Positionals:')
}
- var examples = []
- self.example = function (cmd, description) {
+ let examples = []
+ self.example = (cmd, description) => {
examples.push([cmd, description || ''])
}
- var commands = []
- self.command = function (cmd, description, isDefault, aliases) {
+ let commands = []
+ self.command = function command (cmd, description, isDefault, aliases) {
// the last default wins, so cancel out any previously set default
if (isDefault) {
- commands = commands.map(function (cmdArray) {
+ commands = commands.map((cmdArray) => {
cmdArray[2] = false
return cmdArray
})
}
commands.push([cmd, description || '', isDefault, aliases])
}
- self.getCommands = function () {
- return commands
- }
+ self.getCommands = () => commands
- var descriptions = {}
- self.describe = function (key, desc) {
+ let descriptions = {}
+ self.describe = function describe (key, desc) {
if (typeof key === 'object') {
- Object.keys(key).forEach(function (k) {
+ Object.keys(key).forEach((k) => {
self.describe(k, key[k])
})
} else {
descriptions[key] = desc
}
}
- self.getDescriptions = function () {
- return descriptions
- }
+ self.getDescriptions = () => descriptions
- var epilog
- self.epilog = function (msg) {
+ let epilog
+ self.epilog = (msg) => {
epilog = msg
}
- var wrapSet = false
- var wrap
- self.wrap = function (cols) {
+ let wrapSet = false
+ let wrap
+ self.wrap = (cols) => {
wrapSet = true
wrap = cols
}
@@ -126,41 +139,57 @@ module.exports = function (yargs, y18n) {
return wrap
}
- var deferY18nLookupPrefix = '__yargsString__:'
- self.deferY18nLookup = function (str) {
- return deferY18nLookupPrefix + str
- }
+ const deferY18nLookupPrefix = '__yargsString__:'
+ self.deferY18nLookup = str => deferY18nLookupPrefix + str
- var defaultGroup = 'Options:'
- self.help = function () {
+ const defaultGroup = 'Options:'
+ self.help = function help () {
normalizeAliases()
// handle old demanded API
- var demandedOptions = yargs.getDemandedOptions()
- var demandedCommands = yargs.getDemandedCommands()
- var groups = yargs.getGroups()
- var options = yargs.getOptions()
- var keys = Object.keys(
+ const base$0 = path.basename(yargs.$0)
+ const demandedOptions = yargs.getDemandedOptions()
+ const demandedCommands = yargs.getDemandedCommands()
+ const groups = yargs.getGroups()
+ const options = yargs.getOptions()
+ let keys = Object.keys(
Object.keys(descriptions)
.concat(Object.keys(demandedOptions))
.concat(Object.keys(demandedCommands))
.concat(Object.keys(options.default))
- .reduce(function (acc, key) {
+ .reduce((acc, key) => {
if (key !== '_') acc[key] = true
return acc
}, {})
)
- var theWrap = getWrap()
- var ui = require('cliui')({
+ const theWrap = getWrap()
+ const ui = require('cliui')({
width: theWrap,
wrap: !!theWrap
})
// the usage string.
- if (usage) {
- var u = usage.replace(/\$0/g, yargs.$0)
- ui.div(u + '\n')
+ if (!usageDisabled) {
+ if (usages.length) {
+ // user-defined usage.
+ usages.forEach((usage) => {
+ ui.div(`${usage[0].replace(/\$0/g, base$0)}`)
+ if (usage[1]) {
+ ui.div({text: `${usage[1]}`, padding: [1, 0, 0, 0]})
+ }
+ })
+ ui.div()
+ } else if (commands.length) {
+ let u = null
+ // demonstrate how commands are used.
+ if (demandedCommands._) {
+ u = `${base$0} <${__('command')}>\n`
+ } else {
+ u = `${base$0} [${__('command')}]\n`
+ }
+ ui.div(`${u}`)
+ }
}
// your application's commands, i.e., non-option
@@ -168,15 +197,23 @@ module.exports = function (yargs, y18n) {
if (commands.length) {
ui.div(__('Commands:'))
- commands.forEach(function (command) {
+ const context = yargs.getContext()
+ const parentCommands = context.commands.length ? `${context.commands.join(' ')} ` : ''
+
+ commands.forEach((command) => {
+ const commandString = `${base$0} ${parentCommands}${command[0].replace(/^\$0 ?/, '')}` // drop $0 from default commands.
ui.span(
- {text: command[0], padding: [0, 2, 0, 2], width: maxWidth(commands, theWrap) + 4},
+ {
+ text: commandString,
+ padding: [0, 2, 0, 2],
+ width: maxWidth(commands, theWrap, `${base$0}${parentCommands}`) + 4
+ },
{text: command[1]}
)
- var hints = []
- if (command[2]) hints.push('[' + __('default:').slice(0, -1) + ']') // TODO hacking around i18n here
+ const hints = []
+ if (command[2]) hints.push(`[${__('default:').slice(0, -1)}]`) // TODO hacking around i18n here
if (command[3] && command[3].length) {
- hints.push('[' + __('aliases:') + ' ' + command[3].join(', ') + ']')
+ hints.push(`[${__('aliases:')} ${command[3].join(', ')}]`)
}
if (hints.length) {
ui.div({text: hints.join(' '), padding: [0, 0, 0, 2], align: 'right'})
@@ -190,14 +227,10 @@ module.exports = function (yargs, y18n) {
// perform some cleanup on the keys array, making it
// only include top-level keys not their aliases.
- var aliasKeys = (Object.keys(options.alias) || [])
+ const aliasKeys = (Object.keys(options.alias) || [])
.concat(Object.keys(yargs.parsed.newAliases) || [])
- keys = keys.filter(function (key) {
- return !yargs.parsed.newAliases[key] && aliasKeys.every(function (alias) {
- return (options.alias[alias] || []).indexOf(key) === -1
- })
- })
+ keys = keys.filter(key => !yargs.parsed.newAliases[key] && aliasKeys.every(alias => (options.alias[alias] || []).indexOf(key) === -1))
// populate 'Options:' group with any keys that have not
// explicitly had a group set.
@@ -205,51 +238,54 @@ module.exports = function (yargs, y18n) {
addUngroupedKeys(keys, options.alias, groups)
// display 'Options:' table along with any custom tables:
- Object.keys(groups).forEach(function (groupName) {
+ Object.keys(groups).forEach((groupName) => {
if (!groups[groupName].length) return
ui.div(__(groupName))
// if we've grouped the key 'f', but 'f' aliases 'foobar',
// normalizedKeys should contain only 'foobar'.
- var normalizedKeys = groups[groupName].map(function (key) {
+ const normalizedKeys = groups[groupName].map((key) => {
if (~aliasKeys.indexOf(key)) return key
- for (var i = 0, aliasKey; (aliasKey = aliasKeys[i]) !== undefined; i++) {
+ for (let i = 0, aliasKey; (aliasKey = aliasKeys[i]) !== undefined; i++) {
if (~(options.alias[aliasKey] || []).indexOf(key)) return aliasKey
}
return key
})
// actually generate the switches string --foo, -f, --bar.
- var switches = normalizedKeys.reduce(function (acc, key) {
+ const switches = normalizedKeys.reduce((acc, key) => {
acc[key] = [ key ].concat(options.alias[key] || [])
- .map(function (sw) {
- return (sw.length > 1 ? '--' : '-') + sw
+ .map(sw => {
+ // for the special positional group don't
+ // add '--' or '-' prefix.
+ if (groupName === self.getPositionalGroupName()) return sw
+ else return (sw.length > 1 ? '--' : '-') + sw
})
.join(', ')
return acc
}, {})
- normalizedKeys.forEach(function (key) {
- var kswitch = switches[key]
- var desc = descriptions[key] || ''
- var type = null
+ normalizedKeys.forEach((key) => {
+ const kswitch = switches[key]
+ let desc = descriptions[key] || ''
+ let type = null
if (~desc.lastIndexOf(deferY18nLookupPrefix)) desc = __(desc.substring(deferY18nLookupPrefix.length))
- if (~options.boolean.indexOf(key)) type = '[' + __('boolean') + ']'
- if (~options.count.indexOf(key)) type = '[' + __('count') + ']'
- if (~options.string.indexOf(key)) type = '[' + __('string') + ']'
- if (~options.normalize.indexOf(key)) type = '[' + __('string') + ']'
- if (~options.array.indexOf(key)) type = '[' + __('array') + ']'
- if (~options.number.indexOf(key)) type = '[' + __('number') + ']'
+ if (~options.boolean.indexOf(key)) type = `[${__('boolean')}]`
+ if (~options.count.indexOf(key)) type = `[${__('count')}]`
+ if (~options.string.indexOf(key)) type = `[${__('string')}]`
+ if (~options.normalize.indexOf(key)) type = `[${__('string')}]`
+ if (~options.array.indexOf(key)) type = `[${__('array')}]`
+ if (~options.number.indexOf(key)) type = `[${__('number')}]`
- var extra = [
+ const extra = [
type,
- (key in demandedOptions) ? '[' + __('required') + ']' : null,
- options.choices && options.choices[key] ? '[' + __('choices:') + ' ' +
- self.stringifiedValues(options.choices[key]) + ']' : null,
+ (key in demandedOptions) ? `[${__('required')}]` : null,
+ options.choices && options.choices[key] ? `[${__('choices:')} ${
+ self.stringifiedValues(options.choices[key])}]` : null,
defaultString(options.default[key], options.defaultDescription[key])
].filter(Boolean).join(' ')
@@ -269,11 +305,11 @@ module.exports = function (yargs, y18n) {
if (examples.length) {
ui.div(__('Examples:'))
- examples.forEach(function (example) {
- example[0] = example[0].replace(/\$0/g, yargs.$0)
+ examples.forEach((example) => {
+ example[0] = example[0].replace(/\$0/g, base$0)
})
- examples.forEach(function (example) {
+ examples.forEach((example) => {
if (example[1] === '') {
ui.div(
{
@@ -299,8 +335,8 @@ module.exports = function (yargs, y18n) {
// the usage string.
if (epilog) {
- var e = epilog.replace(/\$0/g, yargs.$0)
- ui.div(e + '\n')
+ const e = epilog.replace(/\$0/g, base$0)
+ ui.div(`${e}\n`)
}
return ui.toString()
@@ -308,19 +344,20 @@ module.exports = function (yargs, y18n) {
// return the maximum width of a string
// in the left-hand column of a table.
- function maxWidth (table, theWrap) {
- var width = 0
+ function maxWidth (table, theWrap, modifier) {
+ let width = 0
// table might be of the form [leftColumn],
// or {key: leftColumn}
if (!Array.isArray(table)) {
- table = Object.keys(table).map(function (key) {
- return [table[key]]
- })
+ table = Object.keys(table).map(key => [table[key]])
}
- table.forEach(function (v) {
- width = Math.max(stringWidth(v[0]), width)
+ table.forEach((v) => {
+ width = Math.max(
+ stringWidth(modifier ? `${modifier} ${v[0]}` : v[0]),
+ width
+ )
})
// if we've enabled 'wrap' we should limit
@@ -334,11 +371,11 @@ module.exports = function (yargs, y18n) {
// are copied to the keys being aliased.
function normalizeAliases () {
// handle old demanded API
- var demandedOptions = yargs.getDemandedOptions()
- var options = yargs.getOptions()
+ const demandedOptions = yargs.getDemandedOptions()
+ const options = yargs.getOptions()
- ;(Object.keys(options.alias) || []).forEach(function (key) {
- options.alias[key].forEach(function (alias) {
+ ;(Object.keys(options.alias) || []).forEach((key) => {
+ options.alias[key].forEach((alias) => {
// copy descriptions.
if (descriptions[alias]) self.describe(key, descriptions[alias])
// copy demanded.
@@ -357,43 +394,41 @@ module.exports = function (yargs, y18n) {
// given a set of keys, place any keys that are
// ungrouped under the 'Options:' grouping.
function addUngroupedKeys (keys, aliases, groups) {
- var groupedKeys = []
- var toCheck = null
- Object.keys(groups).forEach(function (group) {
+ let groupedKeys = []
+ let toCheck = null
+ Object.keys(groups).forEach((group) => {
groupedKeys = groupedKeys.concat(groups[group])
})
- keys.forEach(function (key) {
+ keys.forEach((key) => {
toCheck = [key].concat(aliases[key])
- if (!toCheck.some(function (k) {
- return groupedKeys.indexOf(k) !== -1
- })) {
+ if (!toCheck.some(k => groupedKeys.indexOf(k) !== -1)) {
groups[defaultGroup].push(key)
}
})
return groupedKeys
}
- self.showHelp = function (level) {
+ self.showHelp = (level) => {
const logger = yargs._getLoggerInstance()
if (!level) level = 'error'
- var emit = typeof level === 'function' ? level : logger[level]
+ const emit = typeof level === 'function' ? level : logger[level]
emit(self.help())
}
- self.functionDescription = function (fn) {
- var description = fn.name ? require('decamelize')(fn.name, '-') : __('generated-value')
+ self.functionDescription = (fn) => {
+ const description = fn.name ? require('decamelize')(fn.name, '-') : __('generated-value')
return ['(', description, ')'].join('')
}
- self.stringifiedValues = function (values, separator) {
- var string = ''
- var sep = separator || ', '
- var array = [].concat(values)
+ self.stringifiedValues = function stringifiedValues (values, separator) {
+ let string = ''
+ const sep = separator || ', '
+ const array = [].concat(values)
if (!values || !array.length) return string
- array.forEach(function (value) {
+ array.forEach((value) => {
if (string.length) string += sep
string += JSON.stringify(value)
})
@@ -404,7 +439,7 @@ module.exports = function (yargs, y18n) {
// format the default-value-string displayed in
// the right-hand column.
function defaultString (value, defaultDescription) {
- var string = '[' + __('default:') + ' '
+ let string = `[${__('default:')} `
if (value === undefined && !defaultDescription) return null
@@ -413,7 +448,7 @@ module.exports = function (yargs, y18n) {
} else {
switch (typeof value) {
case 'string':
- string += JSON.stringify(value)
+ string += `"${value}"`
break
case 'object':
string += JSON.stringify(value)
@@ -423,12 +458,12 @@ module.exports = function (yargs, y18n) {
}
}
- return string + ']'
+ return `${string}]`
}
// guess the width of the console window, max-width 80.
function windowWidth () {
- var maxWidth = 80
+ const maxWidth = 80
if (typeof process === 'object' && process.stdout && process.stdout.columns) {
return Math.min(maxWidth, process.stdout.columns)
} else {
@@ -437,47 +472,47 @@ module.exports = function (yargs, y18n) {
}
// logic for displaying application version.
- var version = null
- self.version = function (ver) {
+ let version = null
+ self.version = (ver) => {
version = ver
}
- self.showVersion = function () {
+ self.showVersion = () => {
const logger = yargs._getLoggerInstance()
- if (typeof version === 'function') logger.log(version())
- else logger.log(version)
+ logger.log(version)
}
- self.reset = function (localLookup) {
+ self.reset = function reset (localLookup) {
// do not reset wrap here
// do not reset fails here
failMessage = null
failureOutput = false
- usage = undefined
+ usages = []
+ usageDisabled = false
epilog = undefined
examples = []
commands = []
- descriptions = objFilter(descriptions, function (k, v) {
- return !localLookup[k]
- })
+ descriptions = objFilter(descriptions, (k, v) => !localLookup[k])
return self
}
- var frozen
- self.freeze = function () {
+ let frozen
+ self.freeze = function freeze () {
frozen = {}
frozen.failMessage = failMessage
frozen.failureOutput = failureOutput
- frozen.usage = usage
+ frozen.usages = usages
+ frozen.usageDisabled = usageDisabled
frozen.epilog = epilog
frozen.examples = examples
frozen.commands = commands
frozen.descriptions = descriptions
}
- self.unfreeze = function () {
+ self.unfreeze = function unfreeze () {
failMessage = frozen.failMessage
failureOutput = frozen.failureOutput
- usage = frozen.usage
+ usages = frozen.usages
+ usageDisabled = frozen.usageDisabled
epilog = frozen.epilog
examples = frozen.examples
commands = frozen.commands
diff --git a/node_modules/yargs/lib/validation.js b/node_modules/yargs/lib/validation.js
index 2f9ff8e6c..1eee2fb02 100644
--- a/node_modules/yargs/lib/validation.js
+++ b/node_modules/yargs/lib/validation.js
@@ -1,16 +1,18 @@
+'use strict'
+const argsert = require('./argsert')
const objFilter = require('./obj-filter')
const specialKeys = ['$0', '--', '_']
// validation-type-stuff, missing params,
// bad implications, custom checks.
-module.exports = function (yargs, usage, y18n) {
+module.exports = function validation (yargs, usage, y18n) {
const __ = y18n.__
const __n = y18n.__n
const self = {}
// validate appropriate # of non-option
// arguments were provided, i.e., '_'.
- self.nonOptionCount = function (argv) {
+ self.nonOptionCount = function nonOptionCount (argv) {
const demandedCommands = yargs.getDemandedCommands()
// don't count currently executing commands
const _s = argv._.length - yargs.getContext().commands.length
@@ -44,7 +46,7 @@ module.exports = function (yargs, usage, y18n) {
// validate the appropriate # of <required>
// positional arguments were provided:
- self.positionalCount = function (required, observed) {
+ self.positionalCount = function positionalCount (required, observed) {
if (observed < required) {
usage.fail(
__('Not enough non-option arguments: got %s, need at least %s', observed, required)
@@ -54,14 +56,14 @@ module.exports = function (yargs, usage, y18n) {
// make sure that any args that require an
// value (--foo=bar), have a value.
- self.missingArgumentValue = function (argv) {
+ self.missingArgumentValue = function missingArgumentValue (argv) {
const defaultValues = [true, false, '']
const options = yargs.getOptions()
if (options.requiresArg.length > 0) {
const missingRequiredArgs = []
- options.requiresArg.forEach(function (key) {
+ options.requiresArg.forEach((key) => {
const value = argv[key]
// if a value is explicitly requested,
@@ -85,11 +87,11 @@ module.exports = function (yargs, usage, y18n) {
}
// make sure all the required arguments are present.
- self.requiredArguments = function (argv) {
+ self.requiredArguments = function requiredArguments (argv) {
const demandedOptions = yargs.getDemandedOptions()
- var missing = null
+ let missing = null
- Object.keys(demandedOptions).forEach(function (key) {
+ Object.keys(demandedOptions).forEach((key) => {
if (!argv.hasOwnProperty(key) || typeof argv[key] === 'undefined') {
missing = missing || {}
missing[key] = demandedOptions[key]
@@ -98,14 +100,14 @@ module.exports = function (yargs, usage, y18n) {
if (missing) {
const customMsgs = []
- Object.keys(missing).forEach(function (key) {
+ Object.keys(missing).forEach((key) => {
const msg = missing[key]
if (msg && customMsgs.indexOf(msg) < 0) {
customMsgs.push(msg)
}
})
- const customMsg = customMsgs.length ? '\n' + customMsgs.join('\n') : ''
+ const customMsg = customMsgs.length ? `\n${customMsgs.join('\n')}` : ''
usage.fail(__n(
'Missing required argument: %s',
@@ -117,33 +119,23 @@ module.exports = function (yargs, usage, y18n) {
}
// check for unknown arguments (strict-mode).
- self.unknownArguments = function (argv, aliases, positionalMap) {
- const aliasLookup = {}
- const descriptions = usage.getDescriptions()
- const demandedOptions = yargs.getDemandedOptions()
+ self.unknownArguments = function unknownArguments (argv, aliases, positionalMap) {
const commandKeys = yargs.getCommandInstance().getCommands()
const unknown = []
const currentContext = yargs.getContext()
- Object.keys(aliases).forEach(function (key) {
- aliases[key].forEach(function (alias) {
- aliasLookup[alias] = key
- })
- })
-
- Object.keys(argv).forEach(function (key) {
+ Object.keys(argv).forEach((key) => {
if (specialKeys.indexOf(key) === -1 &&
- !descriptions.hasOwnProperty(key) &&
- !demandedOptions.hasOwnProperty(key) &&
!positionalMap.hasOwnProperty(key) &&
!yargs._getParseContext().hasOwnProperty(key) &&
- !aliasLookup.hasOwnProperty(key)) {
+ !aliases.hasOwnProperty(key)
+ ) {
unknown.push(key)
}
})
if (commandKeys.length > 0) {
- argv._.slice(currentContext.commands.length).forEach(function (key) {
+ argv._.slice(currentContext.commands.length).forEach((key) => {
if (commandKeys.indexOf(key) === -1) {
unknown.push(key)
}
@@ -161,18 +153,19 @@ module.exports = function (yargs, usage, y18n) {
}
// validate arguments limited to enumerated choices
- self.limitedChoices = function (argv) {
+ self.limitedChoices = function limitedChoices (argv) {
const options = yargs.getOptions()
const invalid = {}
if (!Object.keys(options.choices).length) return
- Object.keys(argv).forEach(function (key) {
+ Object.keys(argv).forEach((key) => {
if (specialKeys.indexOf(key) === -1 &&
options.choices.hasOwnProperty(key)) {
- [].concat(argv[key]).forEach(function (value) {
+ [].concat(argv[key]).forEach((value) => {
// TODO case-insensitive configurability
- if (options.choices[key].indexOf(value) === -1) {
+ if (options.choices[key].indexOf(value) === -1 &&
+ value !== undefined) {
invalid[key] = (invalid[key] || []).concat(value)
}
})
@@ -183,31 +176,31 @@ module.exports = function (yargs, usage, y18n) {
if (!invalidKeys.length) return
- var msg = __('Invalid values:')
- invalidKeys.forEach(function (key) {
- msg += '\n ' + __(
+ let msg = __('Invalid values:')
+ invalidKeys.forEach((key) => {
+ msg += `\n ${__(
'Argument: %s, Given: %s, Choices: %s',
key,
usage.stringifiedValues(invalid[key]),
usage.stringifiedValues(options.choices[key])
- )
+ )}`
})
usage.fail(msg)
}
// custom checks, added using the `check` option on yargs.
- var checks = []
- self.check = function (f, global) {
+ let checks = []
+ self.check = function check (f, global) {
checks.push({
func: f,
- global: global
+ global
})
}
- self.customChecks = function (argv, aliases) {
- for (var i = 0, f; (f = checks[i]) !== undefined; i++) {
- var func = f.func
- var result = null
+ self.customChecks = function customChecks (argv, aliases) {
+ for (let i = 0, f; (f = checks[i]) !== undefined; i++) {
+ const func = f.func
+ let result = null
try {
result = func(argv, aliases)
} catch (err) {
@@ -224,107 +217,129 @@ module.exports = function (yargs, usage, y18n) {
}
// check implications, argument foo implies => argument bar.
- var implied = {}
- self.implies = function (key, value) {
+ let implied = {}
+ self.implies = function implies (key, value) {
+ argsert('<string|object> [array|number|string]', [key, value], arguments.length)
+
if (typeof key === 'object') {
- Object.keys(key).forEach(function (k) {
+ Object.keys(key).forEach((k) => {
self.implies(k, key[k])
})
} else {
yargs.global(key)
- implied[key] = value
+ if (!implied[key]) {
+ implied[key] = []
+ }
+ if (Array.isArray(value)) {
+ value.forEach((i) => self.implies(key, i))
+ } else {
+ implied[key].push(value)
+ }
}
}
- self.getImplied = function () {
+ self.getImplied = function getImplied () {
return implied
}
- self.implications = function (argv) {
+ self.implications = function implications (argv) {
const implyFail = []
- Object.keys(implied).forEach(function (key) {
- var num
+ Object.keys(implied).forEach((key) => {
const origKey = key
- var value = implied[key]
-
- // convert string '1' to number 1
- num = Number(key)
- key = isNaN(num) ? key : num
-
- if (typeof key === 'number') {
- // check length of argv._
- key = argv._.length >= key
- } else if (key.match(/^--no-.+/)) {
- // check if key doesn't exist
- key = key.match(/^--no-(.+)/)[1]
- key = !argv[key]
- } else {
- // check if key exists
- key = argv[key]
- }
-
- num = Number(value)
- value = isNaN(num) ? value : num
+ ;(implied[key] || []).forEach((value) => {
+ let num
+ let key = origKey
+ const origValue = value
+
+ // convert string '1' to number 1
+ num = Number(key)
+ key = isNaN(num) ? key : num
+
+ if (typeof key === 'number') {
+ // check length of argv._
+ key = argv._.length >= key
+ } else if (key.match(/^--no-.+/)) {
+ // check if key doesn't exist
+ key = key.match(/^--no-(.+)/)[1]
+ key = !argv[key]
+ } else {
+ // check if key exists
+ key = argv[key]
+ }
- if (typeof value === 'number') {
- value = argv._.length >= value
- } else if (value.match(/^--no-.+/)) {
- value = value.match(/^--no-(.+)/)[1]
- value = !argv[value]
- } else {
- value = argv[value]
- }
+ num = Number(value)
+ value = isNaN(num) ? value : num
- if (key && !value) {
- implyFail.push(origKey)
- }
+ if (typeof value === 'number') {
+ value = argv._.length >= value
+ } else if (value.match(/^--no-.+/)) {
+ value = value.match(/^--no-(.+)/)[1]
+ value = !argv[value]
+ } else {
+ value = argv[value]
+ }
+ if (key && !value) {
+ implyFail.push(` ${origKey} -> ${origValue}`)
+ }
+ })
})
if (implyFail.length) {
- var msg = __('Implications failed:') + '\n'
+ let msg = `${__('Implications failed:')}\n`
- implyFail.forEach(function (key) {
- msg += (' ' + key + ' -> ' + implied[key])
+ implyFail.forEach((value) => {
+ msg += (value)
})
usage.fail(msg)
}
}
- var conflicting = {}
- self.conflicts = function (key, value) {
+ let conflicting = {}
+ self.conflicts = function conflicts (key, value) {
+ argsert('<string|object> [array|string]', [key, value], arguments.length)
+
if (typeof key === 'object') {
- Object.keys(key).forEach(function (k) {
+ Object.keys(key).forEach((k) => {
self.conflicts(k, key[k])
})
} else {
yargs.global(key)
- conflicting[key] = value
+ if (!conflicting[key]) {
+ conflicting[key] = []
+ }
+ if (Array.isArray(value)) {
+ value.forEach((i) => self.conflicts(key, i))
+ } else {
+ conflicting[key].push(value)
+ }
}
}
- self.getConflicting = function () {
- return conflicting
- }
-
- self.conflicting = function (argv) {
- var args = Object.getOwnPropertyNames(argv)
-
- args.forEach(function (arg) {
- if (conflicting[arg] && args.indexOf(conflicting[arg]) !== -1) {
- usage.fail(__('Arguments %s and %s are mutually exclusive', arg, conflicting[arg]))
+ self.getConflicting = () => conflicting
+
+ self.conflicting = function conflictingFn (argv) {
+ Object.keys(argv).forEach((key) => {
+ if (conflicting[key]) {
+ conflicting[key].forEach((value) => {
+ // we default keys to 'undefined' that have been configured, we should not
+ // apply conflicting check unless they are a value other than 'undefined'.
+ if (value && argv[key] !== undefined && argv[value] !== undefined) {
+ usage.fail(__(`Arguments ${key} and ${value} are mutually exclusive`))
+ }
+ })
}
})
}
- self.recommendCommands = function (cmd, potentialCommands) {
+ self.recommendCommands = function recommendCommands (cmd, potentialCommands) {
const distance = require('./levenshtein')
const threshold = 3 // if it takes more than three edits, let's move on.
- potentialCommands = potentialCommands.sort(function (a, b) { return b.length - a.length })
+ potentialCommands = potentialCommands.sort((a, b) => b.length - a.length)
- var recommended = null
- var bestDistance = Infinity
- for (var i = 0, candidate; (candidate = potentialCommands[i]) !== undefined; i++) {
- var d = distance(cmd, candidate)
+ let recommended = null
+ let bestDistance = Infinity
+ for (let i = 0, candidate; (candidate = potentialCommands[i]) !== undefined; i++) {
+ const d = distance(cmd, candidate)
if (d <= threshold && d < bestDistance) {
bestDistance = d
recommended = candidate
@@ -333,27 +348,21 @@ module.exports = function (yargs, usage, y18n) {
if (recommended) usage.fail(__('Did you mean %s?', recommended))
}
- self.reset = function (localLookup) {
- implied = objFilter(implied, function (k, v) {
- return !localLookup[k]
- })
- conflicting = objFilter(conflicting, function (k, v) {
- return !localLookup[k]
- })
- checks = checks.filter(function (c) {
- return c.global
- })
+ self.reset = function reset (localLookup) {
+ implied = objFilter(implied, (k, v) => !localLookup[k])
+ conflicting = objFilter(conflicting, (k, v) => !localLookup[k])
+ checks = checks.filter(c => c.global)
return self
}
- var frozen
- self.freeze = function () {
+ let frozen
+ self.freeze = function freeze () {
frozen = {}
frozen.implied = implied
frozen.checks = checks
frozen.conflicting = conflicting
}
- self.unfreeze = function () {
+ self.unfreeze = function unfreeze () {
implied = frozen.implied
checks = frozen.checks
conflicting = frozen.conflicting
diff --git a/node_modules/yargs/lib/yerror.js b/node_modules/yargs/lib/yerror.js
index ad96a8776..53375a0f7 100644
--- a/node_modules/yargs/lib/yerror.js
+++ b/node_modules/yargs/lib/yerror.js
@@ -1,3 +1,4 @@
+'use strict'
function YError (msg) {
this.name = 'YError'
this.message = msg || 'yargs error'
diff --git a/node_modules/yargs/locales/en.json b/node_modules/yargs/locales/en.json
index 4a618e705..fc65c2a0d 100644
--- a/node_modules/yargs/locales/en.json
+++ b/node_modules/yargs/locales/en.json
@@ -36,5 +36,7 @@
"Show help": "Show help",
"Show version number": "Show version number",
"Did you mean %s?": "Did you mean %s?",
- "Arguments %s and %s are mutually exclusive" : "Arguments %s and %s are mutually exclusive"
+ "Arguments %s and %s are mutually exclusive" : "Arguments %s and %s are mutually exclusive",
+ "Positionals:": "Positionals:",
+ "command": "command"
}
diff --git a/node_modules/yargs/locales/hi.json b/node_modules/yargs/locales/hi.json
index 2a9826d96..2cd677acb 100644
--- a/node_modules/yargs/locales/hi.json
+++ b/node_modules/yargs/locales/hi.json
@@ -35,5 +35,8 @@
"Path to JSON config file": "JSON config फाइल का पथ",
"Show help": "सहायता दिखाएँ",
"Show version number": "Version संख्या दिखाएँ",
- "Did you mean %s?": "क्या आपका मतलब है %s?"
+ "Did you mean %s?": "क्या आपका मतलब है %s?",
+ "Arguments %s and %s are mutually exclusive" : "तर्क %s और %s परस्पर अनन्य हैं",
+ "Positionals:": "स्थानीय:",
+ "command": "आदेश"
}
diff --git a/node_modules/yargs/locales/id.json b/node_modules/yargs/locales/id.json
index a06e8608d..87e441cd8 100644
--- a/node_modules/yargs/locales/id.json
+++ b/node_modules/yargs/locales/id.json
@@ -36,5 +36,8 @@
"Path to JSON config file": "Alamat berkas konfigurasi JSON",
"Show help": "Lihat bantuan",
"Show version number": "Lihat nomor versi",
- "Did you mean %s?": "Maksud Anda: %s?"
+ "Did you mean %s?": "Maksud Anda: %s?",
+ "Arguments %s and %s are mutually exclusive" : "Argumen %s dan %s saling eksklusif",
+ "Positionals:": "Posisional-posisional:",
+ "command": "perintah"
}
diff --git a/node_modules/yargs/locales/ja.json b/node_modules/yargs/locales/ja.json
index 45a64a812..64ee6d3fb 100644
--- a/node_modules/yargs/locales/ja.json
+++ b/node_modules/yargs/locales/ja.json
@@ -35,5 +35,8 @@
"Path to JSON config file": "JSONの設定ファイルまでのpath",
"Show help": "ヘルプを表示",
"Show version number": "バージョンを表示",
- "Did you mean %s?": "もしかして %s?"
+ "Did you mean %s?": "もしかして %s?",
+ "Arguments %s and %s are mutually exclusive" : "引数 %s と %s は同時に指定できません",
+ "Positionals:": "位置:",
+ "command": "コマンド"
}
diff --git a/node_modules/yargs/locales/ko.json b/node_modules/yargs/locales/ko.json
index e71498479..0eaeab2f8 100644
--- a/node_modules/yargs/locales/ko.json
+++ b/node_modules/yargs/locales/ko.json
@@ -35,5 +35,8 @@
"Path to JSON config file": "JSON 설정파일 경로",
"Show help": "도움말을 보여줍니다",
"Show version number": "버전 넘버를 보여줍니다",
- "Did you mean %s?": "찾고계신게 %s입니까?"
+ "Did you mean %s?": "찾고계신게 %s입니까?",
+ "Arguments %s and %s are mutually exclusive" : "%s와 %s 인자는 같이 사용될 수 없습니다",
+ "Positionals:": "위치:",
+ "command": "명령"
}
diff --git a/node_modules/yargs/locales/nl.json b/node_modules/yargs/locales/nl.json
index fc029dbeb..1d144724e 100644
--- a/node_modules/yargs/locales/nl.json
+++ b/node_modules/yargs/locales/nl.json
@@ -35,5 +35,8 @@
"Path to JSON config file": "Pad naar JSON configuratiebestand",
"Show help": "Toon help",
"Show version number": "Toon versie nummer",
- "Did you mean %s?": "Bedoelde u misschien %s?"
+ "Did you mean %s?": "Bedoelde u misschien %s?",
+ "Arguments %s and %s are mutually exclusive": "Argumenten %s en %s zijn onderling uitsluitend",
+ "Positionals:": "Positie-afhankelijke argumenten",
+ "command": "commando"
}
diff --git a/node_modules/yargs/locales/pl.json b/node_modules/yargs/locales/pl.json
index 1c834f693..6926a4548 100644
--- a/node_modules/yargs/locales/pl.json
+++ b/node_modules/yargs/locales/pl.json
@@ -35,5 +35,8 @@
"Path to JSON config file": "Ścieżka do pliku konfiguracyjnego JSON",
"Show help": "Pokaż pomoc",
"Show version number": "Pokaż numer wersji",
- "Did you mean %s?": "Czy chodziło Ci o %s?"
+ "Did you mean %s?": "Czy chodziło Ci o %s?",
+ "Arguments %s and %s are mutually exclusive": "Argumenty %s i %s wzajemnie się wykluczają",
+ "Positionals:": "Pozycyjne:",
+ "command": "polecenie"
}
diff --git a/node_modules/yargs/locales/pt_BR.json b/node_modules/yargs/locales/pt_BR.json
index 60e5ffa24..904cb66eb 100644
--- a/node_modules/yargs/locales/pt_BR.json
+++ b/node_modules/yargs/locales/pt_BR.json
@@ -2,7 +2,7 @@
"Commands:": "Comandos:",
"Options:": "Opções:",
"Examples:": "Exemplos:",
- "boolean": "boolean",
+ "boolean": "booleano",
"count": "contagem",
"string": "string",
"number": "número",
@@ -36,5 +36,7 @@
"Show help": "Exibe ajuda",
"Show version number": "Exibe a versão",
"Did you mean %s?": "Você quis dizer %s?",
- "Arguments %s and %s are mutually exclusive" : "Argumentos %s e %s são mutualmente exclusivos"
+ "Arguments %s and %s are mutually exclusive" : "Argumentos %s e %s são mutualmente exclusivos",
+ "Positionals:": "Posicionais:",
+ "command": "comando"
}
diff --git a/node_modules/yargs/locales/tr.json b/node_modules/yargs/locales/tr.json
index 000060b91..9b06c52a8 100644
--- a/node_modules/yargs/locales/tr.json
+++ b/node_modules/yargs/locales/tr.json
@@ -35,5 +35,7 @@
"Path to JSON config file": "JSON yapılandırma dosya konumu",
"Show help": "Yardım detaylarını göster",
"Show version number": "Versiyon detaylarını göster",
- "Did you mean %s?": "Bunu mu demek istediniz: %s?"
+ "Did you mean %s?": "Bunu mu demek istediniz: %s?",
+ "Positionals:": "Sıralılar:",
+ "command": "komut"
}
diff --git a/node_modules/yargs/node_modules/path-type/index.js b/node_modules/yargs/node_modules/path-type/index.js
deleted file mode 100644
index 4ac9dd967..000000000
--- a/node_modules/yargs/node_modules/path-type/index.js
+++ /dev/null
@@ -1,26 +0,0 @@
-'use strict';
-const fs = require('fs');
-const pify = require('pify');
-
-function type(fn, fn2, fp) {
- if (typeof fp !== 'string') {
- return Promise.reject(new TypeError(`Expected a string, got ${typeof fp}`));
- }
-
- return pify(fs[fn])(fp).then(stats => stats[fn2]());
-}
-
-function typeSync(fn, fn2, fp) {
- if (typeof fp !== 'string') {
- throw new TypeError(`Expected a string, got ${typeof fp}`);
- }
-
- return fs[fn](fp)[fn2]();
-}
-
-exports.file = type.bind(null, 'stat', 'isFile');
-exports.dir = type.bind(null, 'stat', 'isDirectory');
-exports.symlink = type.bind(null, 'lstat', 'isSymbolicLink');
-exports.fileSync = typeSync.bind(null, 'statSync', 'isFile');
-exports.dirSync = typeSync.bind(null, 'statSync', 'isDirectory');
-exports.symlinkSync = typeSync.bind(null, 'lstatSync', 'isSymbolicLink');
diff --git a/node_modules/yargs/node_modules/path-type/license b/node_modules/yargs/node_modules/path-type/license
deleted file mode 100644
index 654d0bfe9..000000000
--- a/node_modules/yargs/node_modules/path-type/license
+++ /dev/null
@@ -1,21 +0,0 @@
-The MIT License (MIT)
-
-Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (sindresorhus.com)
-
-Permission is hereby granted, free of charge, to any person obtaining a copy
-of this software and associated documentation files (the "Software"), to deal
-in the Software without restriction, including without limitation the rights
-to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-copies of the Software, and to permit persons to whom the Software is
-furnished to do so, subject to the following conditions:
-
-The above copyright notice and this permission notice shall be included in
-all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-THE SOFTWARE.
diff --git a/node_modules/yargs/node_modules/path-type/package.json b/node_modules/yargs/node_modules/path-type/package.json
deleted file mode 100644
index 54336f352..000000000
--- a/node_modules/yargs/node_modules/path-type/package.json
+++ /dev/null
@@ -1,48 +0,0 @@
-{
- "name": "path-type",
- "version": "2.0.0",
- "description": "Check if a path is a file, directory, or symlink",
- "license": "MIT",
- "repository": "sindresorhus/path-type",
- "author": {
- "name": "Sindre Sorhus",
- "email": "sindresorhus@gmail.com",
- "url": "sindresorhus.com"
- },
- "engines": {
- "node": ">=4"
- },
- "scripts": {
- "test": "xo && ava"
- },
- "files": [
- "index.js"
- ],
- "keywords": [
- "path",
- "fs",
- "type",
- "is",
- "check",
- "directory",
- "dir",
- "file",
- "filepath",
- "symlink",
- "symbolic",
- "link",
- "stat",
- "stats",
- "filesystem"
- ],
- "dependencies": {
- "pify": "^2.0.0"
- },
- "devDependencies": {
- "ava": "*",
- "xo": "*"
- },
- "xo": {
- "esnext": true
- }
-}
diff --git a/node_modules/yargs/node_modules/path-type/readme.md b/node_modules/yargs/node_modules/path-type/readme.md
deleted file mode 100644
index b1ea61fe9..000000000
--- a/node_modules/yargs/node_modules/path-type/readme.md
+++ /dev/null
@@ -1,42 +0,0 @@
-# path-type [![Build Status](https://travis-ci.org/sindresorhus/path-type.svg?branch=master)](https://travis-ci.org/sindresorhus/path-type)
-
-> Check if a path is a file, directory, or symlink
-
-
-## Install
-
-```
-$ npm install --save path-type
-```
-
-
-## Usage
-
-```js
-const pathType = require('path-type');
-
-pathType.file('package.json').then(isFile => {
- console.log(isFile);
- //=> true
-})
-```
-
-
-## API
-
-### .file(path)
-### .dir(path)
-### .symlink(path)
-
-Returns a `Promise` for a `boolean` of whether the path is the checked type.
-
-### .fileSync(path)
-### .dirSync(path)
-### .symlinkSync(path)
-
-Returns a `boolean` of whether the path is the checked type.
-
-
-## License
-
-MIT © [Sindre Sorhus](https://sindresorhus.com)
diff --git a/node_modules/yargs/node_modules/read-pkg-up/index.js b/node_modules/yargs/node_modules/read-pkg-up/index.js
deleted file mode 100644
index 26079760f..000000000
--- a/node_modules/yargs/node_modules/read-pkg-up/index.js
+++ /dev/null
@@ -1,26 +0,0 @@
-'use strict';
-const findUp = require('find-up');
-const readPkg = require('read-pkg');
-
-module.exports = opts => {
- return findUp('package.json', opts).then(fp => {
- if (!fp) {
- return {};
- }
-
- return readPkg(fp, opts).then(pkg => ({pkg, path: fp}));
- });
-};
-
-module.exports.sync = opts => {
- const fp = findUp.sync('package.json', opts);
-
- if (!fp) {
- return {};
- }
-
- return {
- pkg: readPkg.sync(fp, opts),
- path: fp
- };
-};
diff --git a/node_modules/yargs/node_modules/read-pkg-up/license b/node_modules/yargs/node_modules/read-pkg-up/license
deleted file mode 100644
index 654d0bfe9..000000000
--- a/node_modules/yargs/node_modules/read-pkg-up/license
+++ /dev/null
@@ -1,21 +0,0 @@
-The MIT License (MIT)
-
-Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (sindresorhus.com)
-
-Permission is hereby granted, free of charge, to any person obtaining a copy
-of this software and associated documentation files (the "Software"), to deal
-in the Software without restriction, including without limitation the rights
-to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-copies of the Software, and to permit persons to whom the Software is
-furnished to do so, subject to the following conditions:
-
-The above copyright notice and this permission notice shall be included in
-all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-THE SOFTWARE.
diff --git a/node_modules/yargs/node_modules/read-pkg-up/package.json b/node_modules/yargs/node_modules/read-pkg-up/package.json
deleted file mode 100644
index f09bf3c35..000000000
--- a/node_modules/yargs/node_modules/read-pkg-up/package.json
+++ /dev/null
@@ -1,62 +0,0 @@
-{
- "name": "read-pkg-up",
- "version": "2.0.0",
- "description": "Read the closest package.json file",
- "license": "MIT",
- "repository": "sindresorhus/read-pkg-up",
- "author": {
- "name": "Sindre Sorhus",
- "email": "sindresorhus@gmail.com",
- "url": "sindresorhus.com"
- },
- "engines": {
- "node": ">=4"
- },
- "scripts": {
- "test": "xo && ava"
- },
- "files": [
- "index.js"
- ],
- "keywords": [
- "json",
- "read",
- "parse",
- "file",
- "fs",
- "graceful",
- "load",
- "pkg",
- "package",
- "find",
- "up",
- "find-up",
- "findup",
- "look-up",
- "look",
- "file",
- "search",
- "match",
- "package",
- "resolve",
- "parent",
- "parents",
- "folder",
- "directory",
- "dir",
- "walk",
- "walking",
- "path"
- ],
- "dependencies": {
- "find-up": "^2.0.0",
- "read-pkg": "^2.0.0"
- },
- "devDependencies": {
- "ava": "*",
- "xo": "*"
- },
- "xo": {
- "esnext": true
- }
-}
diff --git a/node_modules/yargs/node_modules/read-pkg-up/readme.md b/node_modules/yargs/node_modules/read-pkg-up/readme.md
deleted file mode 100644
index ba18780f9..000000000
--- a/node_modules/yargs/node_modules/read-pkg-up/readme.md
+++ /dev/null
@@ -1,80 +0,0 @@
-# read-pkg-up [![Build Status](https://travis-ci.org/sindresorhus/read-pkg-up.svg?branch=master)](https://travis-ci.org/sindresorhus/read-pkg-up)
-
-> Read the closest package.json file
-
-
-## Why
-
-- [Finds the closest package.json](https://github.com/sindresorhus/find-up)
-- [Gracefully handles filesystem issues](https://github.com/isaacs/node-graceful-fs)
-- [Strips UTF-8 BOM](https://github.com/sindresorhus/strip-bom)
-- [Throws more helpful JSON errors](https://github.com/sindresorhus/parse-json)
-- [Normalizes the data](https://github.com/npm/normalize-package-data#what-normalization-currently-entails)
-
-
-## Install
-
-```
-$ npm install --save read-pkg-up
-```
-
-
-## Usage
-
-```js
-const readPkgUp = require('read-pkg-up');
-
-readPkgUp().then(result => {
- console.log(result);
- /*
- {
- pkg: {
- name: 'awesome-package',
- version: '1.0.0',
- ...
- },
- path: '/Users/sindresorhus/dev/awesome-package/package.json'
- }
- */
-});
-```
-
-
-## API
-
-### readPkgUp([options])
-
-Returns a `Promise` for the result object.
-
-### readPkgUp.sync([options])
-
-Returns the result object.
-
-#### options
-
-##### cwd
-
-Type: `string`<br>
-Default: `.`
-
-Directory to start looking for a package.json file.
-
-##### normalize
-
-Type: `boolean`<br>
-Default: `true`
-
-[Normalize](https://github.com/npm/normalize-package-data#what-normalization-currently-entails) the package data.
-
-
-## Related
-
-- [read-pkg](https://github.com/sindresorhus/read-pkg) - Read a package.json file
-- [pkg-up](https://github.com/sindresorhus/pkg-up) - Find the closest package.json file
-- [find-up](https://github.com/sindresorhus/find-up) - Find a file by walking up parent directories
-- [pkg-conf](https://github.com/sindresorhus/pkg-conf) - Get namespaced config from the closest package.json
-
-
-## License
-
-MIT © [Sindre Sorhus](https://sindresorhus.com)
diff --git a/node_modules/yargs/node_modules/read-pkg/index.js b/node_modules/yargs/node_modules/read-pkg/index.js
deleted file mode 100644
index dff948b69..000000000
--- a/node_modules/yargs/node_modules/read-pkg/index.js
+++ /dev/null
@@ -1,47 +0,0 @@
-'use strict';
-const path = require('path');
-const loadJsonFile = require('load-json-file');
-const pathType = require('path-type');
-
-module.exports = (fp, opts) => {
- if (typeof fp !== 'string') {
- opts = fp;
- fp = '.';
- }
-
- opts = opts || {};
-
- return pathType.dir(fp)
- .then(isDir => {
- if (isDir) {
- fp = path.join(fp, 'package.json');
- }
-
- return loadJsonFile(fp);
- })
- .then(x => {
- if (opts.normalize !== false) {
- require('normalize-package-data')(x);
- }
-
- return x;
- });
-};
-
-module.exports.sync = (fp, opts) => {
- if (typeof fp !== 'string') {
- opts = fp;
- fp = '.';
- }
-
- opts = opts || {};
- fp = pathType.dirSync(fp) ? path.join(fp, 'package.json') : fp;
-
- const x = loadJsonFile.sync(fp);
-
- if (opts.normalize !== false) {
- require('normalize-package-data')(x);
- }
-
- return x;
-};
diff --git a/node_modules/yargs/node_modules/read-pkg/license b/node_modules/yargs/node_modules/read-pkg/license
deleted file mode 100644
index 654d0bfe9..000000000
--- a/node_modules/yargs/node_modules/read-pkg/license
+++ /dev/null
@@ -1,21 +0,0 @@
-The MIT License (MIT)
-
-Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (sindresorhus.com)
-
-Permission is hereby granted, free of charge, to any person obtaining a copy
-of this software and associated documentation files (the "Software"), to deal
-in the Software without restriction, including without limitation the rights
-to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-copies of the Software, and to permit persons to whom the Software is
-furnished to do so, subject to the following conditions:
-
-The above copyright notice and this permission notice shall be included in
-all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-THE SOFTWARE.
diff --git a/node_modules/yargs/node_modules/read-pkg/package.json b/node_modules/yargs/node_modules/read-pkg/package.json
deleted file mode 100644
index b2322191f..000000000
--- a/node_modules/yargs/node_modules/read-pkg/package.json
+++ /dev/null
@@ -1,45 +0,0 @@
-{
- "name": "read-pkg",
- "version": "2.0.0",
- "description": "Read a package.json file",
- "license": "MIT",
- "repository": "sindresorhus/read-pkg",
- "author": {
- "name": "Sindre Sorhus",
- "email": "sindresorhus@gmail.com",
- "url": "sindresorhus.com"
- },
- "engines": {
- "node": ">=4"
- },
- "scripts": {
- "test": "xo && ava"
- },
- "files": [
- "index.js"
- ],
- "keywords": [
- "json",
- "read",
- "parse",
- "file",
- "fs",
- "graceful",
- "load",
- "pkg",
- "package",
- "normalize"
- ],
- "dependencies": {
- "load-json-file": "^2.0.0",
- "normalize-package-data": "^2.3.2",
- "path-type": "^2.0.0"
- },
- "devDependencies": {
- "ava": "*",
- "xo": "*"
- },
- "xo": {
- "esnext": true
- }
-}
diff --git a/node_modules/yargs/node_modules/read-pkg/readme.md b/node_modules/yargs/node_modules/read-pkg/readme.md
deleted file mode 100644
index 5796008b8..000000000
--- a/node_modules/yargs/node_modules/read-pkg/readme.md
+++ /dev/null
@@ -1,79 +0,0 @@
-# read-pkg [![Build Status](https://travis-ci.org/sindresorhus/read-pkg.svg?branch=master)](https://travis-ci.org/sindresorhus/read-pkg)
-
-> Read a package.json file
-
-
-## Why
-
-- [Gracefully handles filesystem issues](https://github.com/isaacs/node-graceful-fs)
-- [Strips UTF-8 BOM](https://github.com/sindresorhus/strip-bom)
-- [Throws more helpful JSON errors](https://github.com/sindresorhus/parse-json)
-- [Normalizes the data](https://github.com/npm/normalize-package-data#what-normalization-currently-entails)
-
-
-## Install
-
-```
-$ npm install --save read-pkg
-```
-
-
-## Usage
-
-```js
-const readPkg = require('read-pkg');
-
-readPkg().then(pkg => {
- console.log(pkg);
- //=> {name: 'read-pkg', ...}
-});
-
-readPkg(__dirname).then(pkg => {
- console.log(pkg);
- //=> {name: 'read-pkg', ...}
-});
-
-readPkg(path.join('unicorn', 'package.json')).then(pkg => {
- console.log(pkg);
- //=> {name: 'read-pkg', ...}
-});
-```
-
-
-## API
-
-### readPkg([path], [options])
-
-Returns a `Promise` for the parsed JSON.
-
-### readPkg.sync([path], [options])
-
-Returns the parsed JSON.
-
-#### path
-
-Type: `string`<br>
-Default: `.`
-
-Path to a `package.json` file or its directory.
-
-#### options
-
-##### normalize
-
-Type: `boolean`<br>
-Default: `true`
-
-[Normalize](https://github.com/npm/normalize-package-data#what-normalization-currently-entails) the package data.
-
-
-## Related
-
-- [read-pkg-up](https://github.com/sindresorhus/read-pkg-up) - Read the closest package.json file
-- [write-pkg](https://github.com/sindresorhus/write-pkg) - Write a `package.json` file
-- [load-json-file](https://github.com/sindresorhus/load-json-file) - Read and parse a JSON file
-
-
-## License
-
-MIT © [Sindre Sorhus](https://sindresorhus.com)
diff --git a/node_modules/yargs/node_modules/yargs-parser/CHANGELOG.md b/node_modules/yargs/node_modules/yargs-parser/CHANGELOG.md
deleted file mode 100644
index 3ad3df821..000000000
--- a/node_modules/yargs/node_modules/yargs-parser/CHANGELOG.md
+++ /dev/null
@@ -1,223 +0,0 @@
-# Change Log
-
-All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
-
-<a name="7.0.0"></a>
-# [7.0.0](https://github.com/yargs/yargs-parser/compare/v6.0.1...v7.0.0) (2017-05-02)
-
-
-### Chores
-
-* revert populate-- logic ([#91](https://github.com/yargs/yargs-parser/issues/91)) ([6003e6d](https://github.com/yargs/yargs-parser/commit/6003e6d))
-
-
-### BREAKING CHANGES
-
-* populate-- now defaults to false.
-
-
-
-<a name="6.0.1"></a>
-## [6.0.1](https://github.com/yargs/yargs-parser/compare/v6.0.0...v6.0.1) (2017-05-01)
-
-
-### Bug Fixes
-
-* default '--' to undefined when not provided; this is closer to the array API ([#90](https://github.com/yargs/yargs-parser/issues/90)) ([4e739cc](https://github.com/yargs/yargs-parser/commit/4e739cc))
-
-
-
-<a name="6.0.0"></a>
-# [6.0.0](https://github.com/yargs/yargs-parser/compare/v4.2.1...v6.0.0) (2017-05-01)
-
-
-### Bug Fixes
-
-* environment variables should take precedence over config file ([#81](https://github.com/yargs/yargs-parser/issues/81)) ([76cee1f](https://github.com/yargs/yargs-parser/commit/76cee1f))
-* parsing hints should apply for dot notation keys ([#86](https://github.com/yargs/yargs-parser/issues/86)) ([3e47d62](https://github.com/yargs/yargs-parser/commit/3e47d62))
-
-
-### Chores
-
-* upgrade to newest version of camelcase ([#87](https://github.com/yargs/yargs-parser/issues/87)) ([f1903aa](https://github.com/yargs/yargs-parser/commit/f1903aa))
-
-
-### Features
-
-* add -- option which allows arguments after the -- flag to be returned separated from positional arguments ([#84](https://github.com/yargs/yargs-parser/issues/84)) ([2572ca8](https://github.com/yargs/yargs-parser/commit/2572ca8))
-* when parsing stops, we now populate "--" by default ([#88](https://github.com/yargs/yargs-parser/issues/88)) ([cd666db](https://github.com/yargs/yargs-parser/commit/cd666db))
-
-
-### BREAKING CHANGES
-
-* rather than placing arguments in "_", when parsing is stopped via "--"; we now populate an array called "--" by default.
-* camelcase now requires Node 4+.
-* environment variables will now override config files (args, env, config-file, config-object)
-
-
-
-<a name="5.0.0"></a>
-# [5.0.0](https://github.com/yargs/yargs-parser/compare/v4.2.1...v5.0.0) (2017-02-18)
-
-
-### Bug Fixes
-
-* environment variables should take precedence over config file ([#81](https://github.com/yargs/yargs-parser/issues/81)) ([76cee1f](https://github.com/yargs/yargs-parser/commit/76cee1f))
-
-
-### BREAKING CHANGES
-
-* environment variables will now override config files (args, env, config-file, config-object)
-
-
-
-<a name="4.2.1"></a>
-## [4.2.1](https://github.com/yargs/yargs-parser/compare/v4.2.0...v4.2.1) (2017-01-02)
-
-
-### Bug Fixes
-
-* flatten/duplicate regression ([#75](https://github.com/yargs/yargs-parser/issues/75)) ([68d68a0](https://github.com/yargs/yargs-parser/commit/68d68a0))
-
-
-
-<a name="4.2.0"></a>
-# [4.2.0](https://github.com/yargs/yargs-parser/compare/v4.1.0...v4.2.0) (2016-12-01)
-
-
-### Bug Fixes
-
-* inner objects in configs had their keys appended to top-level key when dot-notation was disabled ([#72](https://github.com/yargs/yargs-parser/issues/72)) ([0b1b5f9](https://github.com/yargs/yargs-parser/commit/0b1b5f9))
-
-
-### Features
-
-* allow multiple arrays to be provided, rather than always combining ([#71](https://github.com/yargs/yargs-parser/issues/71)) ([0f0fb2d](https://github.com/yargs/yargs-parser/commit/0f0fb2d))
-
-
-
-<a name="4.1.0"></a>
-# [4.1.0](https://github.com/yargs/yargs-parser/compare/v4.0.2...v4.1.0) (2016-11-07)
-
-
-### Features
-
-* apply coercions to default options ([#65](https://github.com/yargs/yargs-parser/issues/65)) ([c79052b](https://github.com/yargs/yargs-parser/commit/c79052b))
-* handle dot notation boolean options ([#63](https://github.com/yargs/yargs-parser/issues/63)) ([02c3545](https://github.com/yargs/yargs-parser/commit/02c3545))
-
-
-
-<a name="4.0.2"></a>
-## [4.0.2](https://github.com/yargs/yargs-parser/compare/v4.0.1...v4.0.2) (2016-09-30)
-
-
-### Bug Fixes
-
-* whoops, let's make the assign not change the Object key order ([29d069a](https://github.com/yargs/yargs-parser/commit/29d069a))
-
-
-
-<a name="4.0.1"></a>
-## [4.0.1](https://github.com/yargs/yargs-parser/compare/v4.0.0...v4.0.1) (2016-09-30)
-
-
-### Bug Fixes
-
-* lodash.assign was deprecated ([#59](https://github.com/yargs/yargs-parser/issues/59)) ([5e7eb11](https://github.com/yargs/yargs-parser/commit/5e7eb11))
-
-
-
-<a name="4.0.0"></a>
-# [4.0.0](https://github.com/yargs/yargs-parser/compare/v3.2.0...v4.0.0) (2016-09-26)
-
-
-### Bug Fixes
-
-* coerce should be applied to the final objects and arrays created ([#57](https://github.com/yargs/yargs-parser/issues/57)) ([4ca69da](https://github.com/yargs/yargs-parser/commit/4ca69da))
-
-
-### BREAKING CHANGES
-
-* coerce is no longer applied to individual arguments in an implicit array.
-
-
-
-<a name="3.2.0"></a>
-# [3.2.0](https://github.com/yargs/yargs-parser/compare/v3.1.0...v3.2.0) (2016-08-13)
-
-
-### Features
-
-* coerce full array instead of each element ([#51](https://github.com/yargs/yargs-parser/issues/51)) ([cc4dc56](https://github.com/yargs/yargs-parser/commit/cc4dc56))
-
-
-
-<a name="3.1.0"></a>
-# [3.1.0](https://github.com/yargs/yargs-parser/compare/v3.0.0...v3.1.0) (2016-08-09)
-
-
-### Bug Fixes
-
-* address pkgConf parsing bug outlined in [#37](https://github.com/yargs/yargs-parser/issues/37) ([#45](https://github.com/yargs/yargs-parser/issues/45)) ([be76ee6](https://github.com/yargs/yargs-parser/commit/be76ee6))
-* better parsing of negative values ([#44](https://github.com/yargs/yargs-parser/issues/44)) ([2e43692](https://github.com/yargs/yargs-parser/commit/2e43692))
-* check aliases when guessing defaults for arguments fixes [#41](https://github.com/yargs/yargs-parser/issues/41) ([#43](https://github.com/yargs/yargs-parser/issues/43)) ([f3e4616](https://github.com/yargs/yargs-parser/commit/f3e4616))
-
-
-### Features
-
-* added coerce option, for providing specialized argument parsing ([#42](https://github.com/yargs/yargs-parser/issues/42)) ([7b49cd2](https://github.com/yargs/yargs-parser/commit/7b49cd2))
-
-
-
-<a name="3.0.0"></a>
-# [3.0.0](https://github.com/yargs/yargs-parser/compare/v2.4.1...v3.0.0) (2016-08-07)
-
-
-### Bug Fixes
-
-* parsing issue with numeric character in group of options ([#19](https://github.com/yargs/yargs-parser/issues/19)) ([f743236](https://github.com/yargs/yargs-parser/commit/f743236))
-* upgraded lodash.assign ([5d7fdf4](https://github.com/yargs/yargs-parser/commit/5d7fdf4))
-
-### BREAKING CHANGES
-
-* subtle change to how values are parsed in a group of single-character arguments.
-* _first released in 3.1.0, better handling of negative values should be considered a breaking change._
-
-
-
-<a name="2.4.1"></a>
-## [2.4.1](https://github.com/yargs/yargs-parser/compare/v2.4.0...v2.4.1) (2016-07-16)
-
-
-### Bug Fixes
-
-* **count:** do not increment a default value ([#39](https://github.com/yargs/yargs-parser/issues/39)) ([b04a189](https://github.com/yargs/yargs-parser/commit/b04a189))
-
-
-
-<a name="2.4.0"></a>
-# [2.4.0](https://github.com/yargs/yargs-parser/compare/v2.3.0...v2.4.0) (2016-04-11)
-
-
-### Features
-
-* **environment:** Support nested options in environment variables ([#26](https://github.com/yargs/yargs-parser/issues/26)) thanks [@elas7](https://github.com/elas7) \o/ ([020778b](https://github.com/yargs/yargs-parser/commit/020778b))
-
-
-
-<a name="2.3.0"></a>
-# [2.3.0](https://github.com/yargs/yargs-parser/compare/v2.2.0...v2.3.0) (2016-04-09)
-
-
-### Bug Fixes
-
-* **boolean:** fix for boolean options with non boolean defaults (#20) ([2dbe86b](https://github.com/yargs/yargs-parser/commit/2dbe86b)), closes [(#20](https://github.com/(/issues/20)
-* **package:** remove tests from tarball ([0353c0d](https://github.com/yargs/yargs-parser/commit/0353c0d))
-* **parsing:** handle calling short option with an empty string as the next value. ([a867165](https://github.com/yargs/yargs-parser/commit/a867165))
-* boolean flag when next value contains the strings 'true' or 'false'. ([69941a6](https://github.com/yargs/yargs-parser/commit/69941a6))
-* update dependencies; add standard-version bin for next release (#24) ([822d9d5](https://github.com/yargs/yargs-parser/commit/822d9d5))
-
-### Features
-
-* **configuration:** Allow to pass configuration objects to yargs-parser ([0780900](https://github.com/yargs/yargs-parser/commit/0780900))
-* **normalize:** allow normalize to work with arrays ([e0eaa1a](https://github.com/yargs/yargs-parser/commit/e0eaa1a))
diff --git a/node_modules/yargs/node_modules/yargs-parser/LICENSE.txt b/node_modules/yargs/node_modules/yargs-parser/LICENSE.txt
deleted file mode 100644
index 836440bef..000000000
--- a/node_modules/yargs/node_modules/yargs-parser/LICENSE.txt
+++ /dev/null
@@ -1,14 +0,0 @@
-Copyright (c) 2016, Contributors
-
-Permission to use, copy, modify, and/or distribute this software
-for any purpose with or without fee is hereby granted, provided
-that the above copyright notice and this permission notice
-appear in all copies.
-
-THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
-WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
-OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE
-LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES
-OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
-WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
-ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
diff --git a/node_modules/yargs/node_modules/yargs-parser/README.md b/node_modules/yargs/node_modules/yargs-parser/README.md
deleted file mode 100644
index d1817fccc..000000000
--- a/node_modules/yargs/node_modules/yargs-parser/README.md
+++ /dev/null
@@ -1,281 +0,0 @@
-# yargs-parser
-
-[![Build Status](https://travis-ci.org/yargs/yargs-parser.png)](https://travis-ci.org/yargs/yargs-parser)
-[![Coverage Status](https://coveralls.io/repos/yargs/yargs-parser/badge.svg?branch=)](https://coveralls.io/r/yargs/yargs-parser?branch=master)
-[![NPM version](https://img.shields.io/npm/v/yargs-parser.svg)](https://www.npmjs.com/package/yargs-parser)
-[![Windows Tests](https://img.shields.io/appveyor/ci/bcoe/yargs-parser/master.svg?label=Windows%20Tests)](https://ci.appveyor.com/project/bcoe/yargs-parser)
-[![Standard Version](https://img.shields.io/badge/release-standard%20version-brightgreen.svg)](https://github.com/conventional-changelog/standard-version)
-
-
-The mighty option parser used by [yargs](https://github.com/yargs/yargs).
-
-visit the [yargs website](http://yargs.js.org/) for more examples, and thorough usage instructions.
-
-<img width="250" src="https://raw.githubusercontent.com/yargs/yargs-parser/master/yargs-logo.png">
-
-## Example
-
-```sh
-npm i yargs-parser --save
-```
-
-```js
-var argv = require('yargs-parser')(process.argv.slice(2))
-console.log(argv)
-```
-
-```sh
-node example.js --foo=33 --bar hello
-{ _: [], foo: 33, bar: 'hello' }
-```
-
-_or parse a string!_
-
-```js
-var argv = require('./')('--foo=99 --bar=33')
-console.log(argv)
-```
-
-```sh
-{ _: [], foo: 99, bar: 33 }
-```
-
-Convert an array of mixed types before passing to `yargs-parser`:
-
-```js
-var parse = require('yargs-parser')
-parse(['-f', 11, '--zoom', 55].join(' ')) // <-- array to string
-parse(['-f', 11, '--zoom', 55].map(String)) // <-- array of strings
-```
-
-## API
-
-### require('yargs-parser')(args, opts={})
-
-Parses command line arguments returning a simple mapping of keys and values.
-
-**expects:**
-
-* `args`: a string or array of strings representing the options to parse.
-* `opts`: provide a set of hints indicating how `args` should be parsed:
- * `opts.alias`: an object representing the set of aliases for a key: `{alias: {foo: ['f']}}`.
- * `opts.array`: indicate that keys should be parsed as an array: `{array: ['foo', 'bar']}`.
- * `opts.boolean`: arguments should be parsed as booleans: `{boolean: ['x', 'y']}`.
- * `opts.config`: indicate a key that represents a path to a configuration file (this file will be loaded and parsed).
- * `opts.coerce`: provide a custom synchronous function that returns a coerced value from the argument provided
- (or throws an error), e.g. `{coerce: {foo: function (arg) {return modifiedArg}}}`.
- * `opts.count`: indicate a key that should be used as a counter, e.g., `-vvv` = `{v: 3}`.
- * `opts.default`: provide default values for keys: `{default: {x: 33, y: 'hello world!'}}`.
- * `opts.envPrefix`: environment variables (`process.env`) with the prefix provided should be parsed.
- * `opts.narg`: specify that a key requires `n` arguments: `{narg: {x: 2}}`.
- * `opts.normalize`: `path.normalize()` will be applied to values set to this key.
- * `opts.string`: keys should be treated as strings (even if they resemble a number `-x 33`).
- * `opts.configuration`: provide configuration options to the yargs-parser (see: [configuration](#configuration)).
- * `opts.number`: keys should be treated as numbers.
- * `opts['--']`: arguments after the end-of-options flag `--` will be set to the `argv.['--']` array instead of being set to the `argv._` array.
-
-**returns:**
-
-* `obj`: an object representing the parsed value of `args`
- * `key/value`: key value pairs for each argument and their aliases.
- * `_`: an array representing the positional arguments.
- * [optional] `--`: an array with arguments after the end-of-options flag `--`.
-
-### require('yargs-parser').detailed(args, opts={})
-
-Parses a command line string, returning detailed information required by the
-yargs engine.
-
-**expects:**
-
-* `args`: a string or array of strings representing options to parse.
-* `opts`: provide a set of hints indicating how `args`, inputs are identical to `require('yargs-parser')(args, opts={})`.
-
-**returns:**
-
-* `argv`: an object representing the parsed value of `args`
- * `key/value`: key value pairs for each argument and their aliases.
- * `_`: an array representing the positional arguments.
-* `error`: populated with an error object if an exception occurred during parsing.
-* `aliases`: the inferred list of aliases built by combining lists in `opts.alias`.
-* `newAliases`: any new aliases added via camel-case expansion.
-* `configuration`: the configuration loaded from the `yargs` stanza in package.json.
-
-<a name="configuration"></a>
-
-### Configuration
-
-The yargs-parser applies several automated transformations on the keys provided
-in `args`. These features can be turned on and off using the `configuration` field
-of `opts`.
-
-```js
-var parsed = parser(['--no-dice'], {
- configuration: {
- 'boolean-negation': false
- }
-})
-```
-
-### short option groups
-
-* default: `true`.
-* key: `short-option-groups`.
-
-Should a group of short-options be treated as boolean flags?
-
-```sh
-node example.js -abc
-{ _: [], a: true, b: true, c: true }
-```
-
-_if disabled:_
-
-```sh
-node example.js -abc
-{ _: [], abc: true }
-```
-
-### camel-case expansion
-
-* default: `true`.
-* key: `camel-case-expansion`.
-
-Should hyphenated arguments be expanded into camel-case aliases?
-
-```sh
-node example.js --foo-bar
-{ _: [], 'foo-bar': true, fooBar: true }
-```
-
-_if disabled:_
-
-```sh
-node example.js --foo-bar
-{ _: [], 'foo-bar': true }
-```
-
-### dot-notation
-
-* default: `true`
-* key: `dot-notation`
-
-Should keys that contain `.` be treated as objects?
-
-```sh
-node example.js --foo.bar
-{ _: [], foo: { bar: true } }
-```
-
-_if disabled:_
-
-```sh
-node example.js --foo.bar
-{ _: [], "foo.bar": true }
-```
-
-### parse numbers
-
-* default: `true`
-* key: `parse-numbers`
-
-Should keys that look like numbers be treated as such?
-
-```sh
-node example.js --foo=99.3
-{ _: [], foo: 99.3 }
-```
-
-_if disabled:_
-
-```sh
-node example.js --foo=99.3
-{ _: [], foo: "99.3" }
-```
-
-### boolean negation
-
-* default: `true`
-* key: `boolean-negation`
-
-Should variables prefixed with `--no` be treated as negations?
-
-```sh
-node example.js --no-foo
-{ _: [], foo: false }
-```
-
-_if disabled:_
-
-```sh
-node example.js --no-foo
-{ _: [], "no-foo": true }
-```
-
-### duplicate arguments array
-
-* default: `true`
-* key: `duplicate-arguments-array`
-
-Should arguments be coerced into an array when duplicated:
-
-```sh
-node example.js -x 1 -x 2
-{ _: [], x: [1, 2] }
-```
-
-_if disabled:_
-
-```sh
-node example.js -x 1 -x 2
-{ _: [], x: 2 }
-```
-
-### flatten duplicate arrays
-
-* default: `true`
-* key: `flatten-duplicate-arrays`
-
-Should array arguments be coerced into a single array when duplicated:
-
-```sh
-node example.js -x 1 2 -x 3 4
-{ _: [], x: [1, 2, 3, 4] }
-```
-
-_if disabled:_
-
-```sh
-node example.js -x 1 2 -x 3 4
-{ _: [], x: [[1, 2], [3, 4]] }
-```
-
-### populate --
-
-* default: `false`.
-* key: `populate--`
-
-Should unparsed flags be stored in `--` or `_`.
-
-_If disabled:_
-
-```sh
-node example.js a -b -- x y
-{ _: [ 'a', 'x', 'y' ], b: true }
-```
-
-_If enabled:_
-
-```sh
-node example.js a -b -- x y
-{ _: [ 'a' ], '--': [ 'x', 'y' ], b: true }
-```
-
-## Special Thanks
-
-The yargs project evolves from optimist and minimist. It owes its
-existence to a lot of James Halliday's hard work. Thanks [substack](https://github.com/substack) **beep** **boop** \o/
-
-## License
-
-ISC
diff --git a/node_modules/yargs/node_modules/yargs-parser/index.js b/node_modules/yargs/node_modules/yargs-parser/index.js
deleted file mode 100644
index 73154066f..000000000
--- a/node_modules/yargs/node_modules/yargs-parser/index.js
+++ /dev/null
@@ -1,764 +0,0 @@
-var camelCase = require('camelcase')
-var path = require('path')
-var tokenizeArgString = require('./lib/tokenize-arg-string')
-var util = require('util')
-
-function parse (args, opts) {
- if (!opts) opts = {}
- // allow a string argument to be passed in rather
- // than an argv array.
- args = tokenizeArgString(args)
- // aliases might have transitive relationships, normalize this.
- var aliases = combineAliases(opts.alias || {})
- var configuration = assign({
- 'short-option-groups': true,
- 'camel-case-expansion': true,
- 'dot-notation': true,
- 'parse-numbers': true,
- 'boolean-negation': true,
- 'duplicate-arguments-array': true,
- 'flatten-duplicate-arrays': true,
- 'populate--': false
- }, opts.configuration)
- var defaults = opts.default || {}
- var configObjects = opts.configObjects || []
- var envPrefix = opts.envPrefix
- var notFlagsOption = configuration['populate--']
- var notFlagsArgv = notFlagsOption ? '--' : '_'
- var newAliases = {}
- // allow a i18n handler to be passed in, default to a fake one (util.format).
- var __ = opts.__ || function (str) {
- return util.format.apply(util, Array.prototype.slice.call(arguments))
- }
- var error = null
- var flags = {
- aliases: {},
- arrays: {},
- bools: {},
- strings: {},
- numbers: {},
- counts: {},
- normalize: {},
- configs: {},
- defaulted: {},
- nargs: {},
- coercions: {}
- }
- var negative = /^-[0-9]+(\.[0-9]+)?/
-
- ;[].concat(opts.array).filter(Boolean).forEach(function (key) {
- flags.arrays[key] = true
- })
-
- ;[].concat(opts.boolean).filter(Boolean).forEach(function (key) {
- flags.bools[key] = true
- })
-
- ;[].concat(opts.string).filter(Boolean).forEach(function (key) {
- flags.strings[key] = true
- })
-
- ;[].concat(opts.number).filter(Boolean).forEach(function (key) {
- flags.numbers[key] = true
- })
-
- ;[].concat(opts.count).filter(Boolean).forEach(function (key) {
- flags.counts[key] = true
- })
-
- ;[].concat(opts.normalize).filter(Boolean).forEach(function (key) {
- flags.normalize[key] = true
- })
-
- Object.keys(opts.narg || {}).forEach(function (k) {
- flags.nargs[k] = opts.narg[k]
- })
-
- Object.keys(opts.coerce || {}).forEach(function (k) {
- flags.coercions[k] = opts.coerce[k]
- })
-
- if (Array.isArray(opts.config) || typeof opts.config === 'string') {
- ;[].concat(opts.config).filter(Boolean).forEach(function (key) {
- flags.configs[key] = true
- })
- } else {
- Object.keys(opts.config || {}).forEach(function (k) {
- flags.configs[k] = opts.config[k]
- })
- }
-
- // create a lookup table that takes into account all
- // combinations of aliases: {f: ['foo'], foo: ['f']}
- extendAliases(opts.key, aliases, opts.default, flags.arrays)
-
- // apply default values to all aliases.
- Object.keys(defaults).forEach(function (key) {
- (flags.aliases[key] || []).forEach(function (alias) {
- defaults[alias] = defaults[key]
- })
- })
-
- var argv = { _: [] }
-
- Object.keys(flags.bools).forEach(function (key) {
- setArg(key, !(key in defaults) ? false : defaults[key])
- setDefaulted(key)
- })
-
- var notFlags = []
- if (args.indexOf('--') !== -1) {
- notFlags = args.slice(args.indexOf('--') + 1)
- args = args.slice(0, args.indexOf('--'))
- }
-
- for (var i = 0; i < args.length; i++) {
- var arg = args[i]
- var broken
- var key
- var letters
- var m
- var next
- var value
-
- // -- seperated by =
- if (arg.match(/^--.+=/) || (
- !configuration['short-option-groups'] && arg.match(/^-.+=/)
- )) {
- // Using [\s\S] instead of . because js doesn't support the
- // 'dotall' regex modifier. See:
- // http://stackoverflow.com/a/1068308/13216
- m = arg.match(/^--?([^=]+)=([\s\S]*)$/)
-
- // nargs format = '--f=monkey washing cat'
- if (checkAllAliases(m[1], flags.nargs)) {
- args.splice(i + 1, 0, m[2])
- i = eatNargs(i, m[1], args)
- // arrays format = '--f=a b c'
- } else if (checkAllAliases(m[1], flags.arrays) && args.length > i + 1) {
- args.splice(i + 1, 0, m[2])
- i = eatArray(i, m[1], args)
- } else {
- setArg(m[1], m[2])
- }
- } else if (arg.match(/^--no-.+/) && configuration['boolean-negation']) {
- key = arg.match(/^--no-(.+)/)[1]
- setArg(key, false)
-
- // -- seperated by space.
- } else if (arg.match(/^--.+/) || (
- !configuration['short-option-groups'] && arg.match(/^-.+/)
- )) {
- key = arg.match(/^--?(.+)/)[1]
-
- // nargs format = '--foo a b c'
- if (checkAllAliases(key, flags.nargs)) {
- i = eatNargs(i, key, args)
- // array format = '--foo a b c'
- } else if (checkAllAliases(key, flags.arrays) && args.length > i + 1) {
- i = eatArray(i, key, args)
- } else {
- next = args[i + 1]
-
- if (next !== undefined && (!next.match(/^-/) ||
- next.match(negative)) &&
- !checkAllAliases(key, flags.bools) &&
- !checkAllAliases(key, flags.counts)) {
- setArg(key, next)
- i++
- } else if (/^(true|false)$/.test(next)) {
- setArg(key, next)
- i++
- } else {
- setArg(key, defaultForType(guessType(key, flags)))
- }
- }
-
- // dot-notation flag seperated by '='.
- } else if (arg.match(/^-.\..+=/)) {
- m = arg.match(/^-([^=]+)=([\s\S]*)$/)
- setArg(m[1], m[2])
-
- // dot-notation flag seperated by space.
- } else if (arg.match(/^-.\..+/)) {
- next = args[i + 1]
- key = arg.match(/^-(.\..+)/)[1]
-
- if (next !== undefined && !next.match(/^-/) &&
- !checkAllAliases(key, flags.bools) &&
- !checkAllAliases(key, flags.counts)) {
- setArg(key, next)
- i++
- } else {
- setArg(key, defaultForType(guessType(key, flags)))
- }
- } else if (arg.match(/^-[^-]+/) && !arg.match(negative)) {
- letters = arg.slice(1, -1).split('')
- broken = false
-
- for (var j = 0; j < letters.length; j++) {
- next = arg.slice(j + 2)
-
- if (letters[j + 1] && letters[j + 1] === '=') {
- value = arg.slice(j + 3)
- key = letters[j]
-
- // nargs format = '-f=monkey washing cat'
- if (checkAllAliases(key, flags.nargs)) {
- args.splice(i + 1, 0, value)
- i = eatNargs(i, key, args)
- // array format = '-f=a b c'
- } else if (checkAllAliases(key, flags.arrays) && args.length > i + 1) {
- args.splice(i + 1, 0, value)
- i = eatArray(i, key, args)
- } else {
- setArg(key, value)
- }
-
- broken = true
- break
- }
-
- if (next === '-') {
- setArg(letters[j], next)
- continue
- }
-
- // current letter is an alphabetic character and next value is a number
- if (/[A-Za-z]/.test(letters[j]) &&
- /^-?\d+(\.\d*)?(e-?\d+)?$/.test(next)) {
- setArg(letters[j], next)
- broken = true
- break
- }
-
- if (letters[j + 1] && letters[j + 1].match(/\W/)) {
- setArg(letters[j], next)
- broken = true
- break
- } else {
- setArg(letters[j], defaultForType(guessType(letters[j], flags)))
- }
- }
-
- key = arg.slice(-1)[0]
-
- if (!broken && key !== '-') {
- // nargs format = '-f a b c'
- if (checkAllAliases(key, flags.nargs)) {
- i = eatNargs(i, key, args)
- // array format = '-f a b c'
- } else if (checkAllAliases(key, flags.arrays) && args.length > i + 1) {
- i = eatArray(i, key, args)
- } else {
- next = args[i + 1]
-
- if (next !== undefined && (!/^(-|--)[^-]/.test(next) ||
- next.match(negative)) &&
- !checkAllAliases(key, flags.bools) &&
- !checkAllAliases(key, flags.counts)) {
- setArg(key, next)
- i++
- } else if (/^(true|false)$/.test(next)) {
- setArg(key, next)
- i++
- } else {
- setArg(key, defaultForType(guessType(key, flags)))
- }
- }
- }
- } else {
- argv._.push(
- flags.strings['_'] || !isNumber(arg) ? arg : Number(arg)
- )
- }
- }
-
- // order of precedence:
- // 1. command line arg
- // 2. value from env var
- // 3. value from config file
- // 4. value from config objects
- // 5. configured default value
- applyEnvVars(argv, true) // special case: check env vars that point to config file
- applyEnvVars(argv, false)
- setConfig(argv)
- setConfigObjects()
- applyDefaultsAndAliases(argv, flags.aliases, defaults)
- applyCoercions(argv)
-
- // for any counts either not in args or without an explicit default, set to 0
- Object.keys(flags.counts).forEach(function (key) {
- if (!hasKey(argv, key.split('.'))) setArg(key, 0)
- })
-
- // '--' defaults to undefined.
- if (notFlagsOption && notFlags.length) argv[notFlagsArgv] = []
- notFlags.forEach(function (key) {
- argv[notFlagsArgv].push(key)
- })
-
- // how many arguments should we consume, based
- // on the nargs option?
- function eatNargs (i, key, args) {
- var toEat = checkAllAliases(key, flags.nargs)
-
- if (args.length - (i + 1) < toEat) error = Error(__('Not enough arguments following: %s', key))
-
- for (var ii = i + 1; ii < (toEat + i + 1); ii++) {
- setArg(key, args[ii])
- }
-
- return (i + toEat)
- }
-
- // if an option is an array, eat all non-hyphenated arguments
- // following it... YUM!
- // e.g., --foo apple banana cat becomes ["apple", "banana", "cat"]
- function eatArray (i, key, args) {
- var start = i + 1
- var argsToSet = []
- var multipleArrayFlag = i > 0
- for (var ii = i + 1; ii < args.length; ii++) {
- if (/^-/.test(args[ii]) && !negative.test(args[ii])) {
- if (ii === start) {
- setArg(key, defaultForType('array'))
- }
- multipleArrayFlag = true
- break
- }
- i = ii
- argsToSet.push(args[ii])
- }
- if (multipleArrayFlag) {
- setArg(key, argsToSet.map(function (arg) {
- return processValue(key, arg)
- }))
- } else {
- argsToSet.forEach(function (arg) {
- setArg(key, arg)
- })
- }
-
- return i
- }
-
- function setArg (key, val) {
- unsetDefaulted(key)
-
- if (/-/.test(key) && !(flags.aliases[key] && flags.aliases[key].length) && configuration['camel-case-expansion']) {
- var c = camelCase(key)
- flags.aliases[key] = [c]
- newAliases[c] = true
- }
-
- var value = processValue(key, val)
-
- var splitKey = key.split('.')
- setKey(argv, splitKey, value)
-
- // handle populating aliases of the full key
- if (flags.aliases[key]) {
- flags.aliases[key].forEach(function (x) {
- x = x.split('.')
- setKey(argv, x, value)
- })
- }
-
- // handle populating aliases of the first element of the dot-notation key
- if (splitKey.length > 1 && configuration['dot-notation']) {
- ;(flags.aliases[splitKey[0]] || []).forEach(function (x) {
- x = x.split('.')
-
- // expand alias with nested objects in key
- var a = [].concat(splitKey)
- a.shift() // nuke the old key.
- x = x.concat(a)
-
- setKey(argv, x, value)
- })
- }
-
- // Set normalize getter and setter when key is in 'normalize' but isn't an array
- if (checkAllAliases(key, flags.normalize) && !checkAllAliases(key, flags.arrays)) {
- var keys = [key].concat(flags.aliases[key] || [])
- keys.forEach(function (key) {
- argv.__defineSetter__(key, function (v) {
- val = path.normalize(v)
- })
-
- argv.__defineGetter__(key, function () {
- return typeof val === 'string' ? path.normalize(val) : val
- })
- })
- }
- }
-
- function processValue (key, val) {
- // handle parsing boolean arguments --foo=true --bar false.
- if (checkAllAliases(key, flags.bools) || checkAllAliases(key, flags.counts)) {
- if (typeof val === 'string') val = val === 'true'
- }
-
- var value = val
- if (!checkAllAliases(key, flags.strings) && !checkAllAliases(key, flags.coercions)) {
- if (isNumber(val)) value = Number(val)
- if (!isUndefined(val) && !isNumber(val) && checkAllAliases(key, flags.numbers)) value = NaN
- }
-
- // increment a count given as arg (either no value or value parsed as boolean)
- if (checkAllAliases(key, flags.counts) && (isUndefined(value) || typeof value === 'boolean')) {
- value = increment
- }
-
- // Set normalized value when key is in 'normalize' and in 'arrays'
- if (checkAllAliases(key, flags.normalize) && checkAllAliases(key, flags.arrays)) {
- if (Array.isArray(val)) value = val.map(path.normalize)
- else value = path.normalize(val)
- }
- return value
- }
-
- // set args from config.json file, this should be
- // applied last so that defaults can be applied.
- function setConfig (argv) {
- var configLookup = {}
-
- // expand defaults/aliases, in-case any happen to reference
- // the config.json file.
- applyDefaultsAndAliases(configLookup, flags.aliases, defaults)
-
- Object.keys(flags.configs).forEach(function (configKey) {
- var configPath = argv[configKey] || configLookup[configKey]
- if (configPath) {
- try {
- var config = null
- var resolvedConfigPath = path.resolve(process.cwd(), configPath)
-
- if (typeof flags.configs[configKey] === 'function') {
- try {
- config = flags.configs[configKey](resolvedConfigPath)
- } catch (e) {
- config = e
- }
- if (config instanceof Error) {
- error = config
- return
- }
- } else {
- config = require(resolvedConfigPath)
- }
-
- setConfigObject(config)
- } catch (ex) {
- if (argv[configKey]) error = Error(__('Invalid JSON config file: %s', configPath))
- }
- }
- })
- }
-
- // set args from config object.
- // it recursively checks nested objects.
- function setConfigObject (config, prev) {
- Object.keys(config).forEach(function (key) {
- var value = config[key]
- var fullKey = prev ? prev + '.' + key : key
-
- // if the value is an inner object and we have dot-notation
- // enabled, treat inner objects in config the same as
- // heavily nested dot notations (foo.bar.apple).
- if (typeof value === 'object' && !Array.isArray(value) && configuration['dot-notation']) {
- // if the value is an object but not an array, check nested object
- setConfigObject(value, fullKey)
- } else {
- // setting arguments via CLI takes precedence over
- // values within the config file.
- if (!hasKey(argv, fullKey.split('.')) || (flags.defaulted[fullKey])) {
- setArg(fullKey, value)
- }
- }
- })
- }
-
- // set all config objects passed in opts
- function setConfigObjects () {
- if (typeof configObjects === 'undefined') return
- configObjects.forEach(function (configObject) {
- setConfigObject(configObject)
- })
- }
-
- function applyEnvVars (argv, configOnly) {
- if (typeof envPrefix === 'undefined') return
-
- var prefix = typeof envPrefix === 'string' ? envPrefix : ''
- Object.keys(process.env).forEach(function (envVar) {
- if (prefix === '' || envVar.lastIndexOf(prefix, 0) === 0) {
- // get array of nested keys and convert them to camel case
- var keys = envVar.split('__').map(function (key, i) {
- if (i === 0) {
- key = key.substring(prefix.length)
- }
- return camelCase(key)
- })
-
- if (((configOnly && flags.configs[keys.join('.')]) || !configOnly) && (!hasKey(argv, keys) || flags.defaulted[keys.join('.')])) {
- setArg(keys.join('.'), process.env[envVar])
- }
- }
- })
- }
-
- function applyCoercions (argv) {
- var coerce
- Object.keys(argv).forEach(function (key) {
- coerce = checkAllAliases(key, flags.coercions)
- if (typeof coerce === 'function') {
- try {
- argv[key] = coerce(argv[key])
- } catch (err) {
- error = err
- }
- }
- })
- }
-
- function applyDefaultsAndAliases (obj, aliases, defaults) {
- Object.keys(defaults).forEach(function (key) {
- if (!hasKey(obj, key.split('.'))) {
- setKey(obj, key.split('.'), defaults[key])
-
- ;(aliases[key] || []).forEach(function (x) {
- if (hasKey(obj, x.split('.'))) return
- setKey(obj, x.split('.'), defaults[key])
- })
- }
- })
- }
-
- function hasKey (obj, keys) {
- var o = obj
-
- if (!configuration['dot-notation']) keys = [keys.join('.')]
-
- keys.slice(0, -1).forEach(function (key) {
- o = (o[key] || {})
- })
-
- var key = keys[keys.length - 1]
-
- if (typeof o !== 'object') return false
- else return key in o
- }
-
- function setKey (obj, keys, value) {
- var o = obj
-
- if (!configuration['dot-notation']) keys = [keys.join('.')]
-
- keys.slice(0, -1).forEach(function (key) {
- if (o[key] === undefined) o[key] = {}
- o = o[key]
- })
-
- var key = keys[keys.length - 1]
-
- var isTypeArray = checkAllAliases(keys.join('.'), flags.arrays)
- var isValueArray = Array.isArray(value)
- var duplicate = configuration['duplicate-arguments-array']
-
- if (value === increment) {
- o[key] = increment(o[key])
- } else if (Array.isArray(o[key])) {
- if (duplicate && isTypeArray && isValueArray) {
- o[key] = configuration['flatten-duplicate-arrays'] ? o[key].concat(value) : [o[key]].concat([value])
- } else if (!duplicate && Boolean(isTypeArray) === Boolean(isValueArray)) {
- o[key] = value
- } else {
- o[key] = o[key].concat([value])
- }
- } else if (o[key] === undefined && isTypeArray) {
- o[key] = isValueArray ? value : [value]
- } else if (duplicate && !(o[key] === undefined || checkAllAliases(key, flags.bools) || checkAllAliases(keys.join('.'), flags.bools) || checkAllAliases(key, flags.counts))) {
- o[key] = [ o[key], value ]
- } else {
- o[key] = value
- }
- }
-
- // extend the aliases list with inferred aliases.
- function extendAliases () {
- Array.prototype.slice.call(arguments).forEach(function (obj) {
- Object.keys(obj || {}).forEach(function (key) {
- // short-circuit if we've already added a key
- // to the aliases array, for example it might
- // exist in both 'opts.default' and 'opts.key'.
- if (flags.aliases[key]) return
-
- flags.aliases[key] = [].concat(aliases[key] || [])
- // For "--option-name", also set argv.optionName
- flags.aliases[key].concat(key).forEach(function (x) {
- if (/-/.test(x) && configuration['camel-case-expansion']) {
- var c = camelCase(x)
- flags.aliases[key].push(c)
- newAliases[c] = true
- }
- })
- flags.aliases[key].forEach(function (x) {
- flags.aliases[x] = [key].concat(flags.aliases[key].filter(function (y) {
- return x !== y
- }))
- })
- })
- })
- }
-
- // check if a flag is set for any of a key's aliases.
- function checkAllAliases (key, flag) {
- var isSet = false
- var toCheck = [].concat(flags.aliases[key] || [], key)
-
- toCheck.forEach(function (key) {
- if (flag[key]) isSet = flag[key]
- })
-
- return isSet
- }
-
- function setDefaulted (key) {
- [].concat(flags.aliases[key] || [], key).forEach(function (k) {
- flags.defaulted[k] = true
- })
- }
-
- function unsetDefaulted (key) {
- [].concat(flags.aliases[key] || [], key).forEach(function (k) {
- delete flags.defaulted[k]
- })
- }
-
- // return a default value, given the type of a flag.,
- // e.g., key of type 'string' will default to '', rather than 'true'.
- function defaultForType (type) {
- var def = {
- boolean: true,
- string: '',
- number: undefined,
- array: []
- }
-
- return def[type]
- }
-
- // given a flag, enforce a default type.
- function guessType (key, flags) {
- var type = 'boolean'
-
- if (checkAllAliases(key, flags.strings)) type = 'string'
- else if (checkAllAliases(key, flags.numbers)) type = 'number'
- else if (checkAllAliases(key, flags.arrays)) type = 'array'
-
- return type
- }
-
- function isNumber (x) {
- if (!configuration['parse-numbers']) return false
- if (typeof x === 'number') return true
- if (/^0x[0-9a-f]+$/i.test(x)) return true
- return /^[-+]?(?:\d+(?:\.\d*)?|\.\d+)(e[-+]?\d+)?$/.test(x)
- }
-
- function isUndefined (num) {
- return num === undefined
- }
-
- return {
- argv: argv,
- error: error,
- aliases: flags.aliases,
- newAliases: newAliases,
- configuration: configuration
- }
-}
-
-// if any aliases reference each other, we should
-// merge them together.
-function combineAliases (aliases) {
- var aliasArrays = []
- var change = true
- var combined = {}
-
- // turn alias lookup hash {key: ['alias1', 'alias2']} into
- // a simple array ['key', 'alias1', 'alias2']
- Object.keys(aliases).forEach(function (key) {
- aliasArrays.push(
- [].concat(aliases[key], key)
- )
- })
-
- // combine arrays until zero changes are
- // made in an iteration.
- while (change) {
- change = false
- for (var i = 0; i < aliasArrays.length; i++) {
- for (var ii = i + 1; ii < aliasArrays.length; ii++) {
- var intersect = aliasArrays[i].filter(function (v) {
- return aliasArrays[ii].indexOf(v) !== -1
- })
-
- if (intersect.length) {
- aliasArrays[i] = aliasArrays[i].concat(aliasArrays[ii])
- aliasArrays.splice(ii, 1)
- change = true
- break
- }
- }
- }
- }
-
- // map arrays back to the hash-lookup (de-dupe while
- // we're at it).
- aliasArrays.forEach(function (aliasArray) {
- aliasArray = aliasArray.filter(function (v, i, self) {
- return self.indexOf(v) === i
- })
- combined[aliasArray.pop()] = aliasArray
- })
-
- return combined
-}
-
-function assign (defaults, configuration) {
- var o = {}
- configuration = configuration || {}
-
- Object.keys(defaults).forEach(function (k) {
- o[k] = defaults[k]
- })
- Object.keys(configuration).forEach(function (k) {
- o[k] = configuration[k]
- })
-
- return o
-}
-
-// this function should only be called when a count is given as an arg
-// it is NOT called to set a default value
-// thus we can start the count at 1 instead of 0
-function increment (orig) {
- return orig !== undefined ? orig + 1 : 1
-}
-
-function Parser (args, opts) {
- var result = parse(args.slice(), opts)
-
- return result.argv
-}
-
-// parse arguments and return detailed
-// meta information, aliases, etc.
-Parser.detailed = function (args, opts) {
- return parse(args.slice(), opts)
-}
-
-module.exports = Parser
diff --git a/node_modules/yargs/node_modules/yargs-parser/lib/tokenize-arg-string.js b/node_modules/yargs/node_modules/yargs-parser/lib/tokenize-arg-string.js
deleted file mode 100644
index 23d39e1fe..000000000
--- a/node_modules/yargs/node_modules/yargs-parser/lib/tokenize-arg-string.js
+++ /dev/null
@@ -1,34 +0,0 @@
-// take an un-split argv string and tokenize it.
-module.exports = function (argString) {
- if (Array.isArray(argString)) return argString
-
- var i = 0
- var c = null
- var opening = null
- var args = []
-
- for (var ii = 0; ii < argString.length; ii++) {
- c = argString.charAt(ii)
-
- // split on spaces unless we're in quotes.
- if (c === ' ' && !opening) {
- i++
- continue
- }
-
- // don't split the string if we're in matching
- // opening or closing single and double quotes.
- if (c === opening) {
- opening = null
- continue
- } else if ((c === "'" || c === '"') && !opening) {
- opening = c
- continue
- }
-
- if (!args[i]) args[i] = ''
- args[i] += c
- }
-
- return args
-}
diff --git a/node_modules/yargs/node_modules/yargs-parser/package.json b/node_modules/yargs/node_modules/yargs-parser/package.json
deleted file mode 100644
index 5d84e9f19..000000000
--- a/node_modules/yargs/node_modules/yargs-parser/package.json
+++ /dev/null
@@ -1,43 +0,0 @@
-{
- "name": "yargs-parser",
- "version": "7.0.0",
- "description": "the mighty option parser used by yargs",
- "main": "index.js",
- "scripts": {
- "pretest": "standard",
- "test": "nyc mocha test/*.js",
- "coverage": "nyc report --reporter=text-lcov | coveralls",
- "release": "standard-version"
- },
- "repository": {
- "url": "git@github.com:yargs/yargs-parser.git"
- },
- "keywords": [
- "argument",
- "parser",
- "yargs",
- "command",
- "cli",
- "parsing",
- "option",
- "args",
- "argument"
- ],
- "author": "Ben Coe <ben@npmjs.com>",
- "license": "ISC",
- "devDependencies": {
- "chai": "^3.5.0",
- "coveralls": "^2.11.12",
- "mocha": "^3.0.1",
- "nyc": "^10.0.0",
- "standard": "^10.0.2",
- "standard-version": "^4.0.0"
- },
- "dependencies": {
- "camelcase": "^4.1.0"
- },
- "files": [
- "lib",
- "index.js"
- ]
-}
diff --git a/node_modules/yargs/package.json b/node_modules/yargs/package.json
index c9a799f7a..56314fa3a 100644
--- a/node_modules/yargs/package.json
+++ b/node_modules/yargs/package.json
@@ -1,6 +1,6 @@
{
"name": "yargs",
- "version": "8.0.2",
+ "version": "10.0.3",
"description": "yargs the modern, pirate-themed, successor to optimist.",
"main": "./index.js",
"files": [
@@ -12,19 +12,18 @@
"LICENSE"
],
"dependencies": {
- "camelcase": "^4.1.0",
"cliui": "^3.2.0",
"decamelize": "^1.1.1",
+ "find-up": "^2.1.0",
"get-caller-file": "^1.0.1",
"os-locale": "^2.0.0",
- "read-pkg-up": "^2.0.0",
"require-directory": "^2.1.1",
"require-main-filename": "^1.0.1",
"set-blocking": "^2.0.0",
"string-width": "^2.0.0",
"which-module": "^2.0.0",
"y18n": "^3.2.1",
- "yargs-parser": "^7.0.0"
+ "yargs-parser": "^8.0.0"
},
"devDependencies": {
"chai": "^3.4.1",
@@ -35,7 +34,7 @@
"es6-promise": "^4.0.2",
"hashish": "0.0.4",
"mocha": "^3.0.1",
- "nyc": "^10.3.0",
+ "nyc": "^11.2.1",
"rimraf": "^2.5.0",
"standard": "^8.6.0",
"standard-version": "^4.2.0",
@@ -43,7 +42,7 @@
"yargs-test-extends": "^1.0.1"
},
"scripts": {
- "pretest": "standard",
+ "posttest": "standard",
"test": "nyc --cache mocha --require ./test/before.js --timeout=8000 --check-leaks",
"coverage": "nyc report --reporter=text-lcov | coveralls",
"release": "standard-version"
@@ -69,6 +68,6 @@
],
"license": "MIT",
"engine": {
- "node": ">=0.10"
+ "node": ">=4"
}
}
diff --git a/node_modules/yargs/yargs.js b/node_modules/yargs/yargs.js
index 078bf8f14..7f04ab451 100644
--- a/node_modules/yargs/yargs.js
+++ b/node_modules/yargs/yargs.js
@@ -1,5 +1,6 @@
+'use strict'
const argsert = require('./lib/argsert')
-const assign = require('./lib/assign')
+const fs = require('fs')
const Command = require('./lib/command')
const Completion = require('./lib/completion')
const Parser = require('yargs-parser')
@@ -12,18 +13,18 @@ const setBlocking = require('set-blocking')
const applyExtends = require('./lib/apply-extends')
const YError = require('./lib/yerror')
-var exports = module.exports = Yargs
+exports = module.exports = Yargs
function Yargs (processArgs, cwd, parentRequire) {
processArgs = processArgs || [] // handle calling yargs().
const self = {}
- var command = null
- var completion = null
- var groups = {}
- var output = ''
- var preservedGroups = {}
- var usage = null
- var validation = null
+ let command = null
+ let completion = null
+ let groups = {}
+ let output = ''
+ let preservedGroups = {}
+ let usage = null
+ let validation = null
const y18n = Y18n({
directory: path.resolve(__dirname, './locales'),
@@ -34,58 +35,54 @@ function Yargs (processArgs, cwd, parentRequire) {
self.$0 = process.argv
.slice(0, 2)
- .map(function (x, i) {
+ .map((x, i) => {
// ignore the node bin, specify this in your
// bin file with #!/usr/bin/env node
if (i === 0 && /\b(node|iojs)(\.exe)?$/.test(x)) return
- var b = rebase(cwd, x)
+ const b = rebase(cwd, x)
return x.match(/^(\/|([a-zA-Z]:)?\\)/) && b.length < x.length ? b : x
})
.join(' ').trim()
if (process.env._ !== undefined && process.argv[1] === process.env._) {
self.$0 = process.env._.replace(
- path.dirname(process.execPath) + '/', ''
+ `${path.dirname(process.execPath)}/`, ''
)
}
// use context object to keep track of resets, subcommand execution, etc
// submodules should modify and check the state of context as necessary
- const context = { resets: -1, commands: [], files: [] }
- self.getContext = function () {
- return context
- }
+ const context = { resets: -1, commands: [], fullCommands: [], files: [] }
+ self.getContext = () => context
// puts yargs back into an initial state. any keys
// that have been set to "global" will not be reset
// by this action.
- var options
- self.resetOptions = self.reset = function (aliases) {
+ let options
+ self.resetOptions = self.reset = function resetOptions (aliases) {
context.resets++
aliases = aliases || {}
options = options || {}
// put yargs back into an initial state, this
// logic is used to build a nested command
// hierarchy.
- var tmpOptions = {}
+ const tmpOptions = {}
tmpOptions.local = options.local ? options.local : []
tmpOptions.configObjects = options.configObjects ? options.configObjects : []
// if a key has been explicitly set as local,
// we should reset it before passing options to command.
- var localLookup = {}
- tmpOptions.local.forEach(function (l) {
+ const localLookup = {}
+ tmpOptions.local.forEach((l) => {
localLookup[l] = true
- ;(aliases[l] || []).forEach(function (a) {
+ ;(aliases[l] || []).forEach((a) => {
localLookup[a] = true
})
})
// preserve all groups not set to local.
- preservedGroups = Object.keys(groups).reduce(function (acc, groupName) {
- var keys = groups[groupName].filter(function (key) {
- return !(key in localLookup)
- })
+ preservedGroups = Object.keys(groups).reduce((acc, groupName) => {
+ const keys = groups[groupName].filter(key => !(key in localLookup))
if (keys.length > 0) {
acc[groupName] = keys
}
@@ -94,26 +91,22 @@ function Yargs (processArgs, cwd, parentRequire) {
// groups can now be reset
groups = {}
- var arrayOptions = [
+ const arrayOptions = [
'array', 'boolean', 'string', 'requiresArg', 'skipValidation',
'count', 'normalize', 'number'
]
- var objectOptions = [
+ const objectOptions = [
'narg', 'key', 'alias', 'default', 'defaultDescription',
'config', 'choices', 'demandedOptions', 'demandedCommands', 'coerce'
]
- arrayOptions.forEach(function (k) {
- tmpOptions[k] = (options[k] || []).filter(function (k) {
- return !localLookup[k]
- })
+ arrayOptions.forEach((k) => {
+ tmpOptions[k] = (options[k] || []).filter(k => !localLookup[k])
})
- objectOptions.forEach(function (k) {
- tmpOptions[k] = objFilter(options[k], function (k, v) {
- return !localLookup[k]
- })
+ objectOptions.forEach((k) => {
+ tmpOptions[k] = objFilter(options[k], (k, v) => !localLookup[k])
})
tmpOptions.envPrefix = options.envPrefix
@@ -137,7 +130,7 @@ function Yargs (processArgs, cwd, parentRequire) {
self.resetOptions()
// temporary hack: allow "freezing" of reset-able state for parse(msg, cb)
- var frozen
+ let frozen
function freeze () {
frozen = {}
frozen.options = options
@@ -223,7 +216,7 @@ function Yargs (processArgs, cwd, parentRequire) {
function populateParserHintArray (type, keys, value) {
keys = [].concat(keys)
- keys.forEach(function (key) {
+ keys.forEach((key) => {
options[type].push(key)
})
}
@@ -280,14 +273,14 @@ function Yargs (processArgs, cwd, parentRequire) {
function populateParserHintObject (builder, isArray, type, key, value) {
if (Array.isArray(key)) {
// an array of keys with one value ['x', 'y', 'z'], function parse () {}
- var temp = {}
- key.forEach(function (k) {
+ const temp = {}
+ key.forEach((k) => {
temp[k] = value
})
builder(temp)
} else if (typeof key === 'object') {
// an object of key value pairs: {'x': parse () {}, 'y': parse() {}}
- Object.keys(key).forEach(function (k) {
+ Object.keys(key).forEach((k) => {
builder(k, key[k])
})
} else {
@@ -300,7 +293,22 @@ function Yargs (processArgs, cwd, parentRequire) {
}
}
- self.config = function (key, msg, parseFn) {
+ function deleteFromParserHintObject (optionKey) {
+ // delete from all parsing hints:
+ // boolean, array, key, alias, etc.
+ Object.keys(options).forEach((hintKey) => {
+ const hint = options[hintKey]
+ if (Array.isArray(hint)) {
+ if (~hint.indexOf(optionKey)) hint.splice(hint.indexOf(optionKey), 1)
+ } else if (typeof hint === 'object') {
+ delete hint[optionKey]
+ }
+ })
+ // now delete the description from usage.js.
+ delete usage.getDescriptions()[optionKey]
+ }
+
+ self.config = function config (key, msg, parseFn) {
argsert('[object|string] [string|function] [function]', [key, msg, parseFn], arguments.length)
// allow a config object to be provided directly.
if (typeof key === 'object') {
@@ -317,7 +325,7 @@ function Yargs (processArgs, cwd, parentRequire) {
key = key || 'config'
self.describe(key, msg || usage.deferY18nLookup('Path to JSON config file'))
- ;(Array.isArray(key) ? key : [key]).forEach(function (k) {
+ ;(Array.isArray(key) ? key : [key]).forEach((k) => {
options.config[k] = parseFn || true
})
@@ -345,12 +353,12 @@ function Yargs (processArgs, cwd, parentRequire) {
// TODO: deprecate self.demand in favor of
// .demandCommand() .demandOption().
- self.demand = self.required = self.require = function (keys, max, msg) {
+ self.demand = self.required = self.require = function demand (keys, max, msg) {
// you can optionally provide a 'max' key,
// which will raise an exception if too many '_'
// options are provided.
if (Array.isArray(max)) {
- max.forEach(function (key) {
+ max.forEach((key) => {
self.demandOption(key, msg)
})
max = Infinity
@@ -362,7 +370,7 @@ function Yargs (processArgs, cwd, parentRequire) {
if (typeof keys === 'number') {
self.demandCommand(keys, max, msg, msg)
} else if (Array.isArray(keys)) {
- keys.forEach(function (key) {
+ keys.forEach((key) => {
self.demandOption(key, msg)
})
} else {
@@ -376,8 +384,8 @@ function Yargs (processArgs, cwd, parentRequire) {
return self
}
- self.demandCommand = function (min, max, minMsg, maxMsg) {
- argsert('[number] [number|string] [string|null] [string|null]', [min, max, minMsg, maxMsg], arguments.length)
+ self.demandCommand = function demandCommand (min, max, minMsg, maxMsg) {
+ argsert('[number] [number|string] [string|null|undefined] [string|null|undefined]', [min, max, minMsg, maxMsg], arguments.length)
if (typeof min === 'undefined') min = 1
@@ -389,50 +397,52 @@ function Yargs (processArgs, cwd, parentRequire) {
self.global('_', false)
options.demandedCommands._ = {
- min: min,
- max: max,
- minMsg: minMsg,
- maxMsg: maxMsg
+ min,
+ max,
+ minMsg,
+ maxMsg
}
return self
}
- self.getDemandedOptions = function () {
+ self.getDemandedOptions = () => {
argsert([], 0)
return options.demandedOptions
}
- self.getDemandedCommands = function () {
+ self.getDemandedCommands = () => {
argsert([], 0)
return options.demandedCommands
}
self.implies = function (key, value) {
- argsert('<string|object> [string]', [key, value], arguments.length)
+ argsert('<string|object> [number|string|array]', [key, value], arguments.length)
validation.implies(key, value)
return self
}
self.conflicts = function (key1, key2) {
- argsert('<string|object> [string]', [key1, key2], arguments.length)
+ argsert('<string|object> [string|array]', [key1, key2], arguments.length)
validation.conflicts(key1, key2)
return self
}
- self.usage = function (msg, opts) {
- argsert('<string|null|object> [object]', [msg, opts], arguments.length)
+ self.usage = function (msg, description, builder, handler) {
+ argsert('<string|null|undefined> [string|boolean] [function|object] [function]', [msg, description, builder, handler], arguments.length)
- if (!opts && typeof msg === 'object') {
- opts = msg
- msg = null
+ if (description !== undefined) {
+ // .usage() can be used as an alias for defining
+ // a default command.
+ if ((msg || '').match(/^\$0( |$)/)) {
+ return self.command(msg, description, builder, handler)
+ } else {
+ throw new YError('.usage() description must start with $0 if being used as alias for .command()')
+ }
+ } else {
+ usage.usage(msg)
+ return self
}
-
- usage.usage(msg)
-
- if (opts) self.options(opts)
-
- return self
}
self.epilogue = self.epilog = function (msg) {
@@ -453,28 +463,26 @@ function Yargs (processArgs, cwd, parentRequire) {
return self
}
- self.global = function (globals, global) {
+ self.global = function global (globals, global) {
argsert('<string|array> [boolean]', [globals, global], arguments.length)
globals = [].concat(globals)
if (global !== false) {
- options.local = options.local.filter(function (l) {
- return globals.indexOf(l) === -1
- })
+ options.local = options.local.filter(l => globals.indexOf(l) === -1)
} else {
- globals.forEach(function (g) {
+ globals.forEach((g) => {
if (options.local.indexOf(g) === -1) options.local.push(g)
})
}
return self
}
- self.pkgConf = function (key, path) {
+ self.pkgConf = function pkgConf (key, path) {
argsert('<string> [string]', [key, path], arguments.length)
- var conf = null
+ let conf = null
// prefer cwd to require-main-filename in this method
// since we're looking for e.g. "nyc" config in nyc consumer
// rather than "yargs" config in nyc (where nyc is the main filename)
- var obj = pkgUp(path || cwd)
+ const obj = pkgUp(path || cwd)
// If an object exists in the key, add it to options.configObjects
if (obj[key] && typeof obj[key] === 'object') {
@@ -485,28 +493,30 @@ function Yargs (processArgs, cwd, parentRequire) {
return self
}
- var pkgs = {}
+ const pkgs = {}
function pkgUp (path) {
- var npath = path || '*'
+ const npath = path || '*'
if (pkgs[npath]) return pkgs[npath]
- const readPkgUp = require('read-pkg-up')
+ const findUp = require('find-up')
- var obj = {}
+ let obj = {}
try {
- obj = readPkgUp.sync({
+ const pkgJsonPath = findUp.sync('package.json', {
cwd: path || require('require-main-filename')(parentRequire || require),
normalize: false
})
+ obj = JSON.parse(fs.readFileSync(pkgJsonPath))
} catch (noop) {}
- pkgs[npath] = obj.pkg || {}
+ pkgs[npath] = obj || {}
return pkgs[npath]
}
- var parseFn = null
- var parseContext = null
- self.parse = function (args, shortCircuit, _parseFn) {
- argsert('<string|array> [function|boolean|object] [function]', [args, shortCircuit, _parseFn], arguments.length)
+ let parseFn = null
+ let parseContext = null
+ self.parse = function parse (args, shortCircuit, _parseFn) {
+ argsert('[string|array] [function|boolean|object] [function]', [args, shortCircuit, _parseFn], arguments.length)
+ if (typeof args === 'undefined') args = processArgs
// a context object can optionally be provided, this allows
// additional information to be passed to a command handler.
@@ -529,25 +539,21 @@ function Yargs (processArgs, cwd, parentRequire) {
freeze()
if (parseFn) exitProcess = false
- var parsed = self._parseArgs(args, shortCircuit)
+ const parsed = self._parseArgs(args, shortCircuit)
if (parseFn) parseFn(exitError, parsed, output)
unfreeze()
return parsed
}
- self._getParseContext = function () {
- return parseContext || {}
- }
+ self._getParseContext = () => parseContext || {}
- self._hasParseCallback = function () {
- return !!parseFn
- }
+ self._hasParseCallback = () => !!parseFn
- self.option = self.options = function (key, opt) {
+ self.option = self.options = function option (key, opt) {
argsert('<string|object> [object]', [key, opt], arguments.length)
if (typeof key === 'object') {
- Object.keys(key).forEach(function (k) {
+ Object.keys(key).forEach((k) => {
self.options(k, key[k])
})
} else {
@@ -559,7 +565,7 @@ function Yargs (processArgs, cwd, parentRequire) {
if (opt.alias) self.alias(key, opt.alias)
- var demand = opt.demand || opt.required || opt.require
+ const demand = opt.demand || opt.required || opt.require
// deprecated, use 'demandOption' instead
if (demand) {
@@ -570,10 +576,6 @@ function Yargs (processArgs, cwd, parentRequire) {
self.demandOption(key, typeof opt.demandOption === 'string' ? opt.demandOption : undefined)
}
- if ('config' in opt) {
- self.config(key, opt.configParser)
- }
-
if ('conflicts' in opt) {
self.conflicts(key, opt.conflicts)
}
@@ -590,7 +592,11 @@ function Yargs (processArgs, cwd, parentRequire) {
self.nargs(key, opt.nargs)
}
- if ('normalize' in opt) {
+ if (opt.config) {
+ self.config(key, opt.configParser)
+ }
+
+ if (opt.normalize) {
self.normalize(key)
}
@@ -642,8 +648,8 @@ function Yargs (processArgs, cwd, parentRequire) {
self.skipValidation(key)
}
- var desc = opt.describe || opt.description || opt.desc
- if (desc) {
+ const desc = opt.describe || opt.description || opt.desc
+ if (!opt.hidden) {
self.describe(key, desc)
}
@@ -654,29 +660,62 @@ function Yargs (processArgs, cwd, parentRequire) {
return self
}
- self.getOptions = function () {
- return options
+ self.getOptions = () => options
+
+ self.positional = function (key, opts) {
+ argsert('<string> <object>', [key, opts], arguments.length)
+ if (context.resets === 0) {
+ throw new YError(".positional() can only be called in a command's builder function")
+ }
+
+ // .positional() only supports a subset of the configuration
+ // options availble to .option().
+ const supportedOpts = ['default', 'implies', 'normalize',
+ 'choices', 'conflicts', 'coerce', 'type', 'describe',
+ 'desc', 'description', 'alias']
+ opts = objFilter(opts, (k, v) => {
+ let accept = supportedOpts.indexOf(k) !== -1
+ // type can be one of string|number|boolean.
+ if (k === 'type' && ['string', 'number', 'boolean'].indexOf(v) === -1) accept = false
+ return accept
+ })
+
+ // copy over any settings that can be inferred from the command string.
+ const fullCommand = context.fullCommands[context.fullCommands.length - 1]
+ const parseOptions = fullCommand ? command.cmdToParseOptions(fullCommand) : {
+ array: [],
+ alias: {},
+ default: {},
+ demand: {}
+ }
+ Object.keys(parseOptions).forEach((pk) => {
+ if (Array.isArray(parseOptions[pk])) {
+ if (parseOptions[pk].indexOf(key) !== -1) opts[pk] = true
+ } else {
+ if (parseOptions[pk][key] && !(pk in opts)) opts[pk] = parseOptions[pk][key]
+ }
+ })
+ self.group(key, usage.getPositionalGroupName())
+ return self.option(key, opts)
}
- self.group = function (opts, groupName) {
+ self.group = function group (opts, groupName) {
argsert('<string|array> <string>', [opts, groupName], arguments.length)
- var existing = preservedGroups[groupName] || groups[groupName]
+ const existing = preservedGroups[groupName] || groups[groupName]
if (preservedGroups[groupName]) {
// we now only need to track this group name in groups.
delete preservedGroups[groupName]
}
- var seen = {}
- groups[groupName] = (existing || []).concat(opts).filter(function (key) {
+ const seen = {}
+ groups[groupName] = (existing || []).concat(opts).filter((key) => {
if (seen[key]) return false
return (seen[key] = true)
})
return self
}
- self.getGroups = function () {
- // combine explicit and preserved groups. explicit groups should be first
- return assign(groups, preservedGroups)
- }
+ // combine explicit and preserved groups. explicit groups should be first
+ self.getGroups = () => Object.assign({}, groups, preservedGroups)
// as long as options.envPrefix is not undefined,
// parser will apply env vars matching prefix to argv
@@ -688,43 +727,58 @@ function Yargs (processArgs, cwd, parentRequire) {
}
self.wrap = function (cols) {
- argsert('<number|null>', [cols], arguments.length)
+ argsert('<number|null|undefined>', [cols], arguments.length)
usage.wrap(cols)
return self
}
- var strict = false
+ let strict = false
self.strict = function (enabled) {
argsert('[boolean]', [enabled], arguments.length)
strict = enabled !== false
return self
}
- self.getStrict = function () {
- return strict
- }
+ self.getStrict = () => strict
self.showHelp = function (level) {
argsert('[string|function]', [level], arguments.length)
if (!self.parsed) self._parseArgs(processArgs) // run parser, if it has not already been executed.
+ if (command.hasDefaultCommand()) {
+ context.resets++ // override the restriction on top-level positoinals.
+ command.runDefaultBuilderOn(self, true)
+ }
usage.showHelp(level)
return self
}
- var versionOpt = null
- self.version = function (opt, msg, ver) {
- argsert('[string|function] [string|function] [string]', [opt, msg, ver], arguments.length)
+ let versionOpt = null
+ self.version = function version (opt, msg, ver) {
+ const defaultVersionOpt = 'version'
+ argsert('[boolean|string] [string] [string]', [opt, msg, ver], arguments.length)
+
+ // nuke the key previously configured
+ // to return version #.
+ if (versionOpt) {
+ deleteFromParserHintObject(versionOpt)
+ usage.version(undefined)
+ versionOpt = null
+ }
+
if (arguments.length === 0) {
ver = guessVersion()
- opt = 'version'
+ opt = defaultVersionOpt
} else if (arguments.length === 1) {
+ if (opt === false) { // disable default 'version' key.
+ return self
+ }
ver = opt
- opt = 'version'
+ opt = defaultVersionOpt
} else if (arguments.length === 2) {
ver = msg
msg = null
}
- versionOpt = opt
+ versionOpt = typeof opt === 'string' ? opt : defaultVersionOpt
msg = msg || usage.deferY18nLookup('Show version number')
usage.version(ver || undefined)
@@ -734,44 +788,35 @@ function Yargs (processArgs, cwd, parentRequire) {
}
function guessVersion () {
- var obj = pkgUp()
+ const obj = pkgUp()
return obj.version || 'unknown'
}
- var helpOpt = null
- var useHelpOptAsCommand = false // a call to .help() will enable this
- self.addHelpOpt = self.help = function (opt, msg, addImplicitCmd) {
- argsert('[string|boolean] [string|boolean] [boolean]', [opt, msg, addImplicitCmd], arguments.length)
+ let helpOpt = null
+ self.addHelpOpt = self.help = function addHelpOpt (opt, msg) {
+ const defaultHelpOpt = 'help'
+ argsert('[string|boolean] [string]', [opt, msg], arguments.length)
- // argument shuffle
- if (arguments.length === 0) {
- useHelpOptAsCommand = true
- } else if (arguments.length === 1) {
- if (typeof opt === 'boolean') {
- useHelpOptAsCommand = opt
- opt = null
- } else {
- useHelpOptAsCommand = true
- }
- } else if (arguments.length === 2) {
- if (typeof msg === 'boolean') {
- useHelpOptAsCommand = msg
- msg = null
- } else {
- useHelpOptAsCommand = true
- }
- } else {
- useHelpOptAsCommand = Boolean(addImplicitCmd)
+ // nuke the key previously configured
+ // to return help.
+ if (helpOpt) {
+ deleteFromParserHintObject(helpOpt)
+ helpOpt = null
+ }
+
+ if (arguments.length === 1) {
+ if (opt === false) return self
}
+
// use arguments, fallback to defaults for opt and msg
- helpOpt = opt || 'help'
+ helpOpt = typeof opt === 'string' ? opt : defaultHelpOpt
self.boolean(helpOpt)
self.describe(helpOpt, msg || usage.deferY18nLookup('Show help'))
return self
}
- self.showHelpOnFail = function (enabled, message) {
+ self.showHelpOnFail = function showHelpOnFail (enabled, message) {
argsert('[boolean|string] [string]', [enabled, message], arguments.length)
usage.showHelpOnFail(enabled, message)
return self
@@ -786,9 +831,7 @@ function Yargs (processArgs, cwd, parentRequire) {
exitProcess = enabled
return self
}
- self.getExitProcess = function () {
- return exitProcess
- }
+ self.getExitProcess = () => exitProcess
var completionCommand = null
self.completion = function (cmd, desc, fn) {
@@ -818,7 +861,7 @@ function Yargs (processArgs, cwd, parentRequire) {
self.showCompletionScript = function ($0) {
argsert('[string]', [$0], arguments.length)
$0 = $0 || self.$0
- _logger.log(completion.generateCompletionScript($0))
+ _logger.log(completion.generateCompletionScript($0, completionCommand))
return self
}
@@ -845,21 +888,19 @@ function Yargs (processArgs, cwd, parentRequire) {
return self
}
- var detectLocale = true
+ let detectLocale = true
self.detectLocale = function (detect) {
argsert('<boolean>', [detect], arguments.length)
detectLocale = detect
return self
}
- self.getDetectLocale = function () {
- return detectLocale
- }
+ self.getDetectLocale = () => detectLocale
var hasOutput = false
var exitError = null
// maybe exit, always capture
// context about why we wanted to exit.
- self.exit = function (code, err) {
+ self.exit = (code, err) => {
hasOutput = true
exitError = err
if (exitProcess) process.exit(code)
@@ -867,78 +908,66 @@ function Yargs (processArgs, cwd, parentRequire) {
// we use a custom logger that buffers output,
// so that we can print to non-CLIs, e.g., chat-bots.
- var _logger = {
- log: function () {
+ const _logger = {
+ log () {
const args = []
- for (var i = 0; i < arguments.length; i++) args.push(arguments[i])
+ for (let i = 0; i < arguments.length; i++) args.push(arguments[i])
if (!self._hasParseCallback()) console.log.apply(console, args)
hasOutput = true
if (output.length) output += '\n'
output += args.join(' ')
},
- error: function () {
+ error () {
const args = []
- for (var i = 0; i < arguments.length; i++) args.push(arguments[i])
+ for (let i = 0; i < arguments.length; i++) args.push(arguments[i])
if (!self._hasParseCallback()) console.error.apply(console, args)
hasOutput = true
if (output.length) output += '\n'
output += args.join(' ')
}
}
- self._getLoggerInstance = function () {
- return _logger
- }
+ self._getLoggerInstance = () => _logger
// has yargs output an error our help
// message in the current execution context.
- self._hasOutput = function () {
- return hasOutput
- }
+ self._hasOutput = () => hasOutput
- self._setHasOutput = function () {
+ self._setHasOutput = () => {
hasOutput = true
}
- var recommendCommands
+ let recommendCommands
self.recommendCommands = function (recommend) {
argsert('[boolean]', [recommend], arguments.length)
recommendCommands = typeof recommend === 'boolean' ? recommend : true
return self
}
- self.getUsageInstance = function () {
- return usage
- }
+ self.getUsageInstance = () => usage
- self.getValidationInstance = function () {
- return validation
- }
+ self.getValidationInstance = () => validation
- self.getCommandInstance = function () {
- return command
- }
+ self.getCommandInstance = () => command
- self.terminalWidth = function () {
+ self.terminalWidth = () => {
argsert([], 0)
return typeof process.stdout.columns !== 'undefined' ? process.stdout.columns : null
}
Object.defineProperty(self, 'argv', {
- get: function () {
- return self._parseArgs(processArgs)
- },
+ get: () => self._parseArgs(processArgs),
enumerable: true
})
- self._parseArgs = function (args, shortCircuit, _skipValidation, commandIndex) {
- var skipValidation = !!_skipValidation
+ self._parseArgs = function parseArgs (args, shortCircuit, _skipValidation, commandIndex) {
+ let skipValidation = !!_skipValidation
args = args || processArgs
options.__ = y18n.__
options.configuration = pkgUp()['yargs'] || {}
const parsed = Parser.detailed(args, options)
- var argv = parsed.argv
- if (parseContext) argv = assign(argv, parseContext)
- var aliases = parsed.aliases
+ let argv = parsed.argv
+ if (parseContext) argv = Object.assign({}, argv, parseContext)
+ const aliases = parsed.aliases
argv.$0 = self.$0
self.parsed = parsed
@@ -953,34 +982,28 @@ function Yargs (processArgs, cwd, parentRequire) {
return argv
}
- if (argv._.length) {
- // check for helpOpt in argv._ before running commands
- // assumes helpOpt must be valid if useHelpOptAsCommand is true
- if (useHelpOptAsCommand) {
- // consider any multi-char helpOpt alias as a valid help command
- // unless all helpOpt aliases are single-char
- // note that parsed.aliases is a normalized bidirectional map :)
- var helpCmds = [helpOpt].concat(aliases[helpOpt] || [])
- var multiCharHelpCmds = helpCmds.filter(function (k) {
- return k.length > 1
- })
- if (multiCharHelpCmds.length) helpCmds = multiCharHelpCmds
- // look for and strip any helpCmds from argv._
- argv._ = argv._.filter(function (cmd) {
- if (~helpCmds.indexOf(cmd)) {
- argv[helpOpt] = true
- return false
- }
- return true
- })
+ // if there's a handler associated with a
+ // command defer processing to it.
+ if (helpOpt) {
+ // consider any multi-char helpOpt alias as a valid help command
+ // unless all helpOpt aliases are single-char
+ // note that parsed.aliases is a normalized bidirectional map :)
+ const helpCmds = [helpOpt]
+ .concat(aliases[helpOpt] || [])
+ .filter(k => k.length > 1)
+ // check if help should trigger and strip it from _.
+ if (~helpCmds.indexOf(argv._[argv._.length - 1])) {
+ argv._.pop()
+ argv[helpOpt] = true
}
+ }
+ const handlerKeys = command.getCommands()
+ const skipDefaultCommand = argv[helpOpt] && (handlerKeys.length > 1 || handlerKeys[0] !== '$0')
- // if there's a handler associated with a
- // command defer processing to it.
- var handlerKeys = command.getCommands()
+ if (argv._.length) {
if (handlerKeys.length) {
- var firstUnknownCommand
- for (var i = (commandIndex || 0), cmd; argv._[i] !== undefined; i++) {
+ let firstUnknownCommand
+ for (let i = (commandIndex || 0), cmd; argv._[i] !== undefined; i++) {
cmd = String(argv._[i])
if (~handlerKeys.indexOf(cmd) && cmd !== completionCommand) {
setPlaceholderKeys(argv)
@@ -995,7 +1018,7 @@ function Yargs (processArgs, cwd, parentRequire) {
}
// run the default command, if defined
- if (command.hasDefaultCommand() && !argv[helpOpt]) {
+ if (command.hasDefaultCommand() && !skipDefaultCommand) {
setPlaceholderKeys(argv)
return command.runCommand(null, self, parsed)
}
@@ -1013,7 +1036,7 @@ function Yargs (processArgs, cwd, parentRequire) {
self.showCompletionScript()
self.exit(0)
}
- } else if (command.hasDefaultCommand() && !argv[helpOpt]) {
+ } else if (command.hasDefaultCommand() && !skipDefaultCommand) {
setPlaceholderKeys(argv)
return command.runCommand(null, self, parsed)
}
@@ -1025,9 +1048,9 @@ function Yargs (processArgs, cwd, parentRequire) {
// we allow for asynchronous completions,
// e.g., loading in a list of commands from an API.
- var completionArgs = args.slice(args.indexOf('--' + completion.completionKey) + 1)
- completion.getCompletion(completionArgs, function (completions) {
- ;(completions || []).forEach(function (completion) {
+ const completionArgs = args.slice(args.indexOf(`--${completion.completionKey}`) + 1)
+ completion.getCompletion(completionArgs, (completions) => {
+ ;(completions || []).forEach((completion) => {
_logger.log(completion)
})
@@ -1039,7 +1062,7 @@ function Yargs (processArgs, cwd, parentRequire) {
// Handle 'help' and 'version' options
// if we haven't already output help!
if (!hasOutput) {
- Object.keys(argv).forEach(function (key) {
+ Object.keys(argv).forEach((key) => {
if (key === helpOpt && argv[key]) {
if (exitProcess) setBlocking(true)
@@ -1058,9 +1081,7 @@ function Yargs (processArgs, cwd, parentRequire) {
// Check if any of the options to skip validation were provided
if (!skipValidation && options.skipValidation.length > 0) {
- skipValidation = Object.keys(argv).some(function (key) {
- return options.skipValidation.indexOf(key) >= 0 && argv[key] === true
- })
+ skipValidation = Object.keys(argv).some(key => options.skipValidation.indexOf(key) >= 0 && argv[key] === true)
}
// If the help or version options where used and exitProcess is false,
@@ -1082,7 +1103,7 @@ function Yargs (processArgs, cwd, parentRequire) {
return setPlaceholderKeys(argv)
}
- self._runValidation = function (argv, aliases, positionalMap, parseErrors) {
+ self._runValidation = function runValidation (argv, aliases, positionalMap, parseErrors) {
if (parseErrors) throw new YError(parseErrors.message)
validation.nonOptionCount(argv)
validation.missingArgumentValue(argv)
@@ -1107,7 +1128,7 @@ function Yargs (processArgs, cwd, parentRequire) {
}
function setPlaceholderKeys (argv) {
- Object.keys(options.key).forEach(function (key) {
+ Object.keys(options.key).forEach((key) => {
// don't set placeholder keys for dot
// notation options 'foo.bar'.
if (~key.indexOf('.')) return
@@ -1116,6 +1137,11 @@ function Yargs (processArgs, cwd, parentRequire) {
return argv
}
+ // an app should almost always have --version and --help,
+ // if you *really* want to disable this use .help(false)/.version(false).
+ self.help()
+ self.version()
+
return self
}