Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/npm/cli.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGar <gar+gh@danger.computer>2022-08-09 19:45:24 +0300
committerGar <wraithgar@github.com>2022-08-10 19:44:06 +0300
commit7f31b85db650c7a2b3b0577840251f5e25e63a01 (patch)
tree4abf12d96f5561c780e106f4bf6e0edea6dddf88
parent741bccf24ad1fa420a6c6182e04487abc02f8ccf (diff)
deps: nopt@6.0.0
-rwxr-xr-xnode_modules/@npmcli/config/node_modules/nopt/bin/nopt.js56
-rw-r--r--node_modules/@npmcli/config/node_modules/nopt/package.json53
l---------node_modules/node-gyp/node_modules/.bin/nopt (renamed from node_modules/@npmcli/config/node_modules/.bin/nopt)0
-rw-r--r--node_modules/node-gyp/node_modules/nopt/LICENSE (renamed from node_modules/@npmcli/config/node_modules/nopt/LICENSE)0
-rwxr-xr-xnode_modules/node-gyp/node_modules/nopt/bin/nopt.js54
-rw-r--r--node_modules/node-gyp/node_modules/nopt/lib/nopt.js (renamed from node_modules/@npmcli/config/node_modules/nopt/lib/nopt.js)370
-rw-r--r--node_modules/node-gyp/node_modules/nopt/package.json34
-rwxr-xr-xnode_modules/nopt/bin/nopt.js80
-rw-r--r--node_modules/nopt/lib/nopt.js370
-rw-r--r--node_modules/nopt/package.json35
-rw-r--r--package-lock.json43
-rw-r--r--package.json2
-rw-r--r--workspaces/arborist/package.json2
13 files changed, 550 insertions, 549 deletions
diff --git a/node_modules/@npmcli/config/node_modules/nopt/bin/nopt.js b/node_modules/@npmcli/config/node_modules/nopt/bin/nopt.js
deleted file mode 100755
index bb04291c6..000000000
--- a/node_modules/@npmcli/config/node_modules/nopt/bin/nopt.js
+++ /dev/null
@@ -1,56 +0,0 @@
-#!/usr/bin/env node
-var nopt = require('../lib/nopt')
-var path = require('path')
-var types = { num: Number,
- bool: Boolean,
- help: Boolean,
- list: Array,
- 'num-list': [Number, Array],
- 'str-list': [String, Array],
- 'bool-list': [Boolean, Array],
- str: String,
- clear: Boolean,
- config: Boolean,
- length: Number,
- file: path,
-}
-var shorthands = { s: ['--str', 'astring'],
- b: ['--bool'],
- nb: ['--no-bool'],
- tft: ['--bool-list', '--no-bool-list', '--bool-list', 'true'],
- '?': ['--help'],
- h: ['--help'],
- H: ['--help'],
- n: ['--num', '125'],
- c: ['--config'],
- l: ['--length'],
- f: ['--file'],
-}
-var parsed = nopt(types
- , shorthands
- , process.argv
- , 2)
-
-console.log('parsed', parsed)
-
-if (parsed.help) {
- console.log('')
- console.log('nopt cli tester')
- console.log('')
- console.log('types')
- console.log(Object.keys(types).map(function M (t) {
- var type = types[t]
- if (Array.isArray(type)) {
- return [t, type.map(function (mappedType) {
- return mappedType.name
- })]
- }
- return [t, type && type.name]
- }).reduce(function (s, i) {
- s[i[0]] = i[1]
- return s
- }, {}))
- console.log('')
- console.log('shorthands')
- console.log(shorthands)
-}
diff --git a/node_modules/@npmcli/config/node_modules/nopt/package.json b/node_modules/@npmcli/config/node_modules/nopt/package.json
deleted file mode 100644
index a3cd13d8c..000000000
--- a/node_modules/@npmcli/config/node_modules/nopt/package.json
+++ /dev/null
@@ -1,53 +0,0 @@
-{
- "name": "nopt",
- "version": "6.0.0",
- "description": "Option parsing for Node, supporting types, shorthands, etc. Used by npm.",
- "author": "GitHub Inc.",
- "main": "lib/nopt.js",
- "scripts": {
- "preversion": "npm test",
- "postversion": "npm publish",
- "prepublishOnly": "git push origin --follow-tags",
- "test": "tap",
- "lint": "eslint \"**/*.js\"",
- "postlint": "template-oss-check",
- "template-oss-apply": "template-oss-apply --force",
- "lintfix": "npm run lint -- --fix",
- "snap": "tap",
- "posttest": "npm run lint"
- },
- "repository": {
- "type": "git",
- "url": "https://github.com/npm/nopt.git"
- },
- "bin": {
- "nopt": "bin/nopt.js"
- },
- "license": "ISC",
- "dependencies": {
- "abbrev": "^1.0.0"
- },
- "devDependencies": {
- "@npmcli/eslint-config": "^3.0.1",
- "@npmcli/template-oss": "3.5.0",
- "tap": "^16.3.0"
- },
- "tap": {
- "lines": 87,
- "functions": 91,
- "branches": 81,
- "statements": 87
- },
- "files": [
- "bin/",
- "lib/"
- ],
- "engines": {
- "node": "^12.13.0 || ^14.15.0 || >=16.0.0"
- },
- "templateOSS": {
- "//@npmcli/template-oss": "This file is partially managed by @npmcli/template-oss. Edits may be overwritten.",
- "windowsCI": false,
- "version": "3.5.0"
- }
-}
diff --git a/node_modules/@npmcli/config/node_modules/.bin/nopt b/node_modules/node-gyp/node_modules/.bin/nopt
index 6b6566ea7..6b6566ea7 120000
--- a/node_modules/@npmcli/config/node_modules/.bin/nopt
+++ b/node_modules/node-gyp/node_modules/.bin/nopt
diff --git a/node_modules/@npmcli/config/node_modules/nopt/LICENSE b/node_modules/node-gyp/node_modules/nopt/LICENSE
index 19129e315..19129e315 100644
--- a/node_modules/@npmcli/config/node_modules/nopt/LICENSE
+++ b/node_modules/node-gyp/node_modules/nopt/LICENSE
diff --git a/node_modules/node-gyp/node_modules/nopt/bin/nopt.js b/node_modules/node-gyp/node_modules/nopt/bin/nopt.js
new file mode 100755
index 000000000..3232d4c57
--- /dev/null
+++ b/node_modules/node-gyp/node_modules/nopt/bin/nopt.js
@@ -0,0 +1,54 @@
+#!/usr/bin/env node
+var nopt = require("../lib/nopt")
+ , path = require("path")
+ , types = { num: Number
+ , bool: Boolean
+ , help: Boolean
+ , list: Array
+ , "num-list": [Number, Array]
+ , "str-list": [String, Array]
+ , "bool-list": [Boolean, Array]
+ , str: String
+ , clear: Boolean
+ , config: Boolean
+ , length: Number
+ , file: path
+ }
+ , shorthands = { s: [ "--str", "astring" ]
+ , b: [ "--bool" ]
+ , nb: [ "--no-bool" ]
+ , tft: [ "--bool-list", "--no-bool-list", "--bool-list", "true" ]
+ , "?": ["--help"]
+ , h: ["--help"]
+ , H: ["--help"]
+ , n: [ "--num", "125" ]
+ , c: ["--config"]
+ , l: ["--length"]
+ , f: ["--file"]
+ }
+ , parsed = nopt( types
+ , shorthands
+ , process.argv
+ , 2 )
+
+console.log("parsed", parsed)
+
+if (parsed.help) {
+ console.log("")
+ console.log("nopt cli tester")
+ console.log("")
+ console.log("types")
+ console.log(Object.keys(types).map(function M (t) {
+ var type = types[t]
+ if (Array.isArray(type)) {
+ return [t, type.map(function (type) { return type.name })]
+ }
+ return [t, type && type.name]
+ }).reduce(function (s, i) {
+ s[i[0]] = i[1]
+ return s
+ }, {}))
+ console.log("")
+ console.log("shorthands")
+ console.log(shorthands)
+}
diff --git a/node_modules/@npmcli/config/node_modules/nopt/lib/nopt.js b/node_modules/node-gyp/node_modules/nopt/lib/nopt.js
index 5829c2fe0..ecfa5da93 100644
--- a/node_modules/@npmcli/config/node_modules/nopt/lib/nopt.js
+++ b/node_modules/node-gyp/node_modules/nopt/lib/nopt.js
@@ -1,147 +1,130 @@
// info about each config option.
var debug = process.env.DEBUG_NOPT || process.env.NOPT_DEBUG
- ? function () {
- console.error.apply(console, arguments)
- }
+ ? function () { console.error.apply(console, arguments) }
: function () {}
-var url = require('url')
-var path = require('path')
-var Stream = require('stream').Stream
-var abbrev = require('abbrev')
-var os = require('os')
+var url = require("url")
+ , path = require("path")
+ , Stream = require("stream").Stream
+ , abbrev = require("abbrev")
+ , os = require("os")
module.exports = exports = nopt
exports.clean = clean
exports.typeDefs =
- { String: { type: String, validate: validateString },
- Boolean: { type: Boolean, validate: validateBoolean },
- url: { type: url, validate: validateUrl },
- Number: { type: Number, validate: validateNumber },
- path: { type: path, validate: validatePath },
- Stream: { type: Stream, validate: validateStream },
- Date: { type: Date, validate: validateDate },
+ { String : { type: String, validate: validateString }
+ , Boolean : { type: Boolean, validate: validateBoolean }
+ , url : { type: url, validate: validateUrl }
+ , Number : { type: Number, validate: validateNumber }
+ , path : { type: path, validate: validatePath }
+ , Stream : { type: Stream, validate: validateStream }
+ , Date : { type: Date, validate: validateDate }
}
function nopt (types, shorthands, args, slice) {
args = args || process.argv
types = types || {}
shorthands = shorthands || {}
- if (typeof slice !== 'number') {
- slice = 2
- }
+ if (typeof slice !== "number") slice = 2
debug(types, shorthands, args, slice)
args = args.slice(slice)
var data = {}
- var argv = {
- remain: [],
- cooked: args,
- original: args.slice(0),
- }
+ , key
+ , argv = {
+ remain: [],
+ cooked: args,
+ original: args.slice(0)
+ }
parse(args, data, argv.remain, types, shorthands)
// now data is full
clean(data, types, exports.typeDefs)
data.argv = argv
Object.defineProperty(data.argv, 'toString', { value: function () {
- return this.original.map(JSON.stringify).join(' ')
- },
- enumerable: false })
+ return this.original.map(JSON.stringify).join(" ")
+ }, enumerable: false })
return data
}
function clean (data, types, typeDefs) {
typeDefs = typeDefs || exports.typeDefs
var remove = {}
- var typeDefault = [false, true, null, String, Array]
+ , typeDefault = [false, true, null, String, Array]
Object.keys(data).forEach(function (k) {
- if (k === 'argv') {
- return
- }
+ if (k === "argv") return
var val = data[k]
- var isArray = Array.isArray(val)
- var type = types[k]
- if (!isArray) {
- val = [val]
- }
- if (!type) {
- type = typeDefault
- }
- if (type === Array) {
- type = typeDefault.concat(Array)
- }
- if (!Array.isArray(type)) {
- type = [type]
- }
-
- debug('val=%j', val)
- debug('types=', type)
- val = val.map(function (v) {
+ , isArray = Array.isArray(val)
+ , type = types[k]
+ if (!isArray) val = [val]
+ if (!type) type = typeDefault
+ if (type === Array) type = typeDefault.concat(Array)
+ if (!Array.isArray(type)) type = [type]
+
+ debug("val=%j", val)
+ debug("types=", type)
+ val = val.map(function (val) {
// if it's an unknown value, then parse false/true/null/numbers/dates
- if (typeof v === 'string') {
- debug('string %j', v)
- v = v.trim()
- if ((v === 'null' && ~type.indexOf(null))
- || (v === 'true' &&
+ if (typeof val === "string") {
+ debug("string %j", val)
+ val = val.trim()
+ if ((val === "null" && ~type.indexOf(null))
+ || (val === "true" &&
(~type.indexOf(true) || ~type.indexOf(Boolean)))
- || (v === 'false' &&
+ || (val === "false" &&
(~type.indexOf(false) || ~type.indexOf(Boolean)))) {
- v = JSON.parse(v)
- debug('jsonable %j', v)
- } else if (~type.indexOf(Number) && !isNaN(v)) {
- debug('convert to number', v)
- v = +v
- } else if (~type.indexOf(Date) && !isNaN(Date.parse(v))) {
- debug('convert to date', v)
- v = new Date(v)
+ val = JSON.parse(val)
+ debug("jsonable %j", val)
+ } else if (~type.indexOf(Number) && !isNaN(val)) {
+ debug("convert to number", val)
+ val = +val
+ } else if (~type.indexOf(Date) && !isNaN(Date.parse(val))) {
+ debug("convert to date", val)
+ val = new Date(val)
}
}
- if (!Object.prototype.hasOwnProperty.call(types, k)) {
- return v
+ if (!types.hasOwnProperty(k)) {
+ return val
}
// allow `--no-blah` to set 'blah' to null if null is allowed
- if (v === false && ~type.indexOf(null) &&
+ if (val === false && ~type.indexOf(null) &&
!(~type.indexOf(false) || ~type.indexOf(Boolean))) {
- v = null
+ val = null
}
var d = {}
- d[k] = v
- debug('prevalidated val', d, v, types[k])
- if (!validate(d, k, v, types[k], typeDefs)) {
+ d[k] = val
+ debug("prevalidated val", d, val, types[k])
+ if (!validate(d, k, val, types[k], typeDefs)) {
if (exports.invalidHandler) {
- exports.invalidHandler(k, v, types[k], data)
+ exports.invalidHandler(k, val, types[k], data)
} else if (exports.invalidHandler !== false) {
- debug('invalid: ' + k + '=' + v, types[k])
+ debug("invalid: "+k+"="+val, types[k])
}
return remove
}
- debug('validated v', d, v, types[k])
+ debug("validated val", d, val, types[k])
return d[k]
- }).filter(function (v) {
- return v !== remove
- })
+ }).filter(function (val) { return val !== remove })
// if we allow Array specifically, then an empty array is how we
// express 'no value here', not null. Allow it.
if (!val.length && type.indexOf(Array) === -1) {
debug('VAL HAS NO LENGTH, DELETE IT', val, k, type.indexOf(Array))
delete data[k]
- } else if (isArray) {
+ }
+ else if (isArray) {
debug(isArray, data[k], val)
data[k] = val
- } else {
- data[k] = val[0]
- }
+ } else data[k] = val[0]
- debug('k=%s val=%j', k, val, data[k])
+ debug("k=%s val=%j", k, val, data[k])
})
}
@@ -150,21 +133,17 @@ function validateString (data, k, val) {
}
function validatePath (data, k, val) {
- if (val === true) {
- return false
- }
- if (val === null) {
- return true
- }
+ if (val === true) return false
+ if (val === null) return true
val = String(val)
- var isWin = process.platform === 'win32'
- var homePattern = isWin ? /^~(\/|\\)/ : /^~\//
- var home = os.homedir()
+ var isWin = process.platform === 'win32'
+ , homePattern = isWin ? /^~(\/|\\)/ : /^~\//
+ , home = os.homedir()
if (home && val.match(homePattern)) {
- data[k] = path.resolve(home, val.slice(2))
+ data[k] = path.resolve(home, val.substr(2))
} else {
data[k] = path.resolve(val)
}
@@ -172,92 +151,63 @@ function validatePath (data, k, val) {
}
function validateNumber (data, k, val) {
- debug('validate Number %j %j %j', k, val, isNaN(val))
- if (isNaN(val)) {
- return false
- }
+ debug("validate Number %j %j %j", k, val, isNaN(val))
+ if (isNaN(val)) return false
data[k] = +val
}
function validateDate (data, k, val) {
var s = Date.parse(val)
- debug('validate Date %j %j %j', k, val, s)
- if (isNaN(s)) {
- return false
- }
+ debug("validate Date %j %j %j", k, val, s)
+ if (isNaN(s)) return false
data[k] = new Date(val)
}
function validateBoolean (data, k, val) {
- if (val instanceof Boolean) {
- val = val.valueOf()
- } else if (typeof val === 'string') {
- if (!isNaN(val)) {
- val = !!(+val)
- } else if (val === 'null' || val === 'false') {
- val = false
- } else {
- val = true
- }
- } else {
- val = !!val
- }
+ if (val instanceof Boolean) val = val.valueOf()
+ else if (typeof val === "string") {
+ if (!isNaN(val)) val = !!(+val)
+ else if (val === "null" || val === "false") val = false
+ else val = true
+ } else val = !!val
data[k] = val
}
function validateUrl (data, k, val) {
- // Changing this would be a breaking change in the npm cli
- /* eslint-disable-next-line node/no-deprecated-api */
val = url.parse(String(val))
- if (!val.host) {
- return false
- }
+ if (!val.host) return false
data[k] = val.href
}
function validateStream (data, k, val) {
- if (!(val instanceof Stream)) {
- return false
- }
+ if (!(val instanceof Stream)) return false
data[k] = val
}
function validate (data, k, val, type, typeDefs) {
// arrays are lists of types.
if (Array.isArray(type)) {
- for (let i = 0, l = type.length; i < l; i++) {
- if (type[i] === Array) {
- continue
- }
- if (validate(data, k, val, type[i], typeDefs)) {
- return true
- }
+ for (var i = 0, l = type.length; i < l; i ++) {
+ if (type[i] === Array) continue
+ if (validate(data, k, val, type[i], typeDefs)) return true
}
delete data[k]
return false
}
// an array of anything?
- if (type === Array) {
- return true
- }
+ if (type === Array) return true
- // Original comment:
// NaN is poisonous. Means that something is not allowed.
- // New comment: Changing this to an isNaN check breaks a lot of tests.
- // Something is being assumed here that is not actually what happens in
- // practice. Fixing it is outside the scope of getting linting to pass in
- // this repo. Leaving as-is for now.
- /* eslint-disable-next-line no-self-compare */
if (type !== type) {
- debug('Poison NaN', k, val, type)
+ debug("Poison NaN", k, val, type)
delete data[k]
return false
}
// explicit list of values
if (val === type) {
- debug('Explicitly allowed %j', val)
+ debug("Explicitly allowed %j", val)
// if (isArray) (data[k] = data[k] || []).push(val)
// else data[k] = val
data[k] = val
@@ -266,17 +216,14 @@ function validate (data, k, val, type, typeDefs) {
// now go through the list of typeDefs, validate against each one.
var ok = false
- var types = Object.keys(typeDefs)
- for (let i = 0, l = types.length; i < l; i++) {
- debug('test type %j %j %j', k, val, types[i])
+ , types = Object.keys(typeDefs)
+ for (var i = 0, l = types.length; i < l; i ++) {
+ debug("test type %j %j %j", k, val, types[i])
var t = typeDefs[types[i]]
- if (t && (
- (type && type.name && t.type && t.type.name) ?
- (type.name === t.type.name) :
- (type === t.type)
- )) {
+ if (t &&
+ ((type && type.name && t.type && t.type.name) ? (type.name === t.type.name) : (type === t.type))) {
var d = {}
- ok = t.validate(d, k, val) !== false
+ ok = false !== t.validate(d, k, val)
val = d[k]
if (ok) {
// if (isArray) (data[k] = data[k] || []).push(val)
@@ -286,63 +233,60 @@ function validate (data, k, val, type, typeDefs) {
}
}
}
- debug('OK? %j (%j %j %j)', ok, k, val, types[types.length - 1])
+ debug("OK? %j (%j %j %j)", ok, k, val, types[i])
- if (!ok) {
- delete data[k]
- }
+ if (!ok) delete data[k]
return ok
}
function parse (args, data, remain, types, shorthands) {
- debug('parse', args, data, remain)
+ debug("parse", args, data, remain)
- var abbrevs = abbrev(Object.keys(types))
- var shortAbbr = abbrev(Object.keys(shorthands))
+ var key = null
+ , abbrevs = abbrev(Object.keys(types))
+ , shortAbbr = abbrev(Object.keys(shorthands))
- for (var i = 0; i < args.length; i++) {
+ for (var i = 0; i < args.length; i ++) {
var arg = args[i]
- debug('arg', arg)
+ debug("arg", arg)
if (arg.match(/^-{2,}$/)) {
// done with keys.
// the rest are args.
remain.push.apply(remain, args.slice(i + 1))
- args[i] = '--'
+ args[i] = "--"
break
}
var hadEq = false
- if (arg.charAt(0) === '-' && arg.length > 1) {
+ if (arg.charAt(0) === "-" && arg.length > 1) {
var at = arg.indexOf('=')
if (at > -1) {
hadEq = true
- var v = arg.slice(at + 1)
- arg = arg.slice(0, at)
+ var v = arg.substr(at + 1)
+ arg = arg.substr(0, at)
args.splice(i, 1, arg, v)
}
// see if it's a shorthand
// if so, splice and back up to re-parse it.
var shRes = resolveShort(arg, shorthands, shortAbbr, abbrevs)
- debug('arg=%j shRes=%j', arg, shRes)
+ debug("arg=%j shRes=%j", arg, shRes)
if (shRes) {
debug(arg, shRes)
args.splice.apply(args, [i, 1].concat(shRes))
if (arg !== shRes[0]) {
- i--
+ i --
continue
}
}
- arg = arg.replace(/^-+/, '')
+ arg = arg.replace(/^-+/, "")
var no = null
- while (arg.toLowerCase().indexOf('no-') === 0) {
+ while (arg.toLowerCase().indexOf("no-") === 0) {
no = !no
- arg = arg.slice(3)
+ arg = arg.substr(3)
}
- if (abbrevs[arg]) {
- arg = abbrevs[arg]
- }
+ if (abbrevs[arg]) arg = abbrevs[arg]
var argType = types[arg]
var isTypeArray = Array.isArray(argType)
@@ -355,24 +299,20 @@ function parse (args, data, remain, types, shorthands) {
isTypeArray && argType.indexOf(Array) !== -1
// allow unknown things to be arrays if specified multiple times.
- if (
- !Object.prototype.hasOwnProperty.call(types, arg) &&
- Object.prototype.hasOwnProperty.call(data, arg)
- ) {
- if (!Array.isArray(data[arg])) {
+ if (!types.hasOwnProperty(arg) && data.hasOwnProperty(arg)) {
+ if (!Array.isArray(data[arg]))
data[arg] = [data[arg]]
- }
isArray = true
}
var val
- var la = args[i + 1]
+ , la = args[i + 1]
var isBool = typeof no === 'boolean' ||
argType === Boolean ||
isTypeArray && argType.indexOf(Boolean) !== -1 ||
(typeof argType === 'undefined' && !hadEq) ||
- (la === 'false' &&
+ (la === "false" &&
(argType === null ||
isTypeArray && ~argType.indexOf(null)))
@@ -380,13 +320,11 @@ function parse (args, data, remain, types, shorthands) {
// just set and move along
val = !no
// however, also support --bool true or --bool false
- if (la === 'true' || la === 'false') {
+ if (la === "true" || la === "false") {
val = JSON.parse(la)
la = null
- if (no) {
- val = !val
- }
- i++
+ if (no) val = !val
+ i ++
}
// also support "foo":[Boolean, "bar"] and "--foo bar"
@@ -394,55 +332,49 @@ function parse (args, data, remain, types, shorthands) {
if (~argType.indexOf(la)) {
// an explicit type
val = la
- i++
- } else if (la === 'null' && ~argType.indexOf(null)) {
+ i ++
+ } else if ( la === "null" && ~argType.indexOf(null) ) {
// null allowed
val = null
- i++
- } else if (!la.match(/^-{2,}[^-]/) &&
+ i ++
+ } else if ( !la.match(/^-{2,}[^-]/) &&
!isNaN(la) &&
- ~argType.indexOf(Number)) {
+ ~argType.indexOf(Number) ) {
// number
val = +la
- i++
- } else if (!la.match(/^-[^-]/) && ~argType.indexOf(String)) {
+ i ++
+ } else if ( !la.match(/^-[^-]/) && ~argType.indexOf(String) ) {
// string
val = la
- i++
+ i ++
}
}
- if (isArray) {
- (data[arg] = data[arg] || []).push(val)
- } else {
- data[arg] = val
- }
+ if (isArray) (data[arg] = data[arg] || []).push(val)
+ else data[arg] = val
continue
}
if (argType === String) {
if (la === undefined) {
- la = ''
+ la = ""
} else if (la.match(/^-{1,2}[^-]+/)) {
- la = ''
- i--
+ la = ""
+ i --
}
}
if (la && la.match(/^-{2,}$/)) {
la = undefined
- i--
+ i --
}
val = la === undefined ? true : la
- if (isArray) {
- (data[arg] = data[arg] || []).push(val)
- } else {
- data[arg] = val
- }
+ if (isArray) (data[arg] = data[arg] || []).push(val)
+ else data[arg] = val
- i++
+ i ++
continue
}
remain.push(arg)
@@ -457,16 +389,14 @@ function resolveShort (arg, shorthands, shortAbbr, abbrevs) {
arg = arg.replace(/^-+/, '')
// if it's an exact known option, then don't go any further
- if (abbrevs[arg] === arg) {
+ if (abbrevs[arg] === arg)
return null
- }
// if it's an exact known shortopt, same deal
if (shorthands[arg]) {
// make it an array, if it's a list of words
- if (shorthands[arg] && !Array.isArray(shorthands[arg])) {
+ if (shorthands[arg] && !Array.isArray(shorthands[arg]))
shorthands[arg] = shorthands[arg].split(/\s+/)
- }
return shorthands[arg]
}
@@ -476,7 +406,7 @@ function resolveShort (arg, shorthands, shortAbbr, abbrevs) {
if (!singles) {
singles = Object.keys(shorthands).filter(function (s) {
return s.length === 1
- }).reduce(function (l, r) {
+ }).reduce(function (l,r) {
l[r] = true
return l
}, {})
@@ -484,32 +414,28 @@ function resolveShort (arg, shorthands, shortAbbr, abbrevs) {
debug('shorthand singles', singles)
}
- var chrs = arg.split('').filter(function (c) {
+ var chrs = arg.split("").filter(function (c) {
return singles[c]
})
- if (chrs.join('') === arg) {
- return chrs.map(function (c) {
- return shorthands[c]
- }).reduce(function (l, r) {
- return l.concat(r)
- }, [])
- }
+ if (chrs.join("") === arg) return chrs.map(function (c) {
+ return shorthands[c]
+ }).reduce(function (l, r) {
+ return l.concat(r)
+ }, [])
+
// if it's an arg abbrev, and not a literal shorthand, then prefer the arg
- if (abbrevs[arg] && !shorthands[arg]) {
+ if (abbrevs[arg] && !shorthands[arg])
return null
- }
// if it's an abbr for a shorthand, then use that
- if (shortAbbr[arg]) {
+ if (shortAbbr[arg])
arg = shortAbbr[arg]
- }
// make it an array, if it's a list of words
- if (shorthands[arg] && !Array.isArray(shorthands[arg])) {
+ if (shorthands[arg] && !Array.isArray(shorthands[arg]))
shorthands[arg] = shorthands[arg].split(/\s+/)
- }
return shorthands[arg]
}
diff --git a/node_modules/node-gyp/node_modules/nopt/package.json b/node_modules/node-gyp/node_modules/nopt/package.json
new file mode 100644
index 000000000..12ed02da5
--- /dev/null
+++ b/node_modules/node-gyp/node_modules/nopt/package.json
@@ -0,0 +1,34 @@
+{
+ "name": "nopt",
+ "version": "5.0.0",
+ "description": "Option parsing for Node, supporting types, shorthands, etc. Used by npm.",
+ "author": "Isaac Z. Schlueter <i@izs.me> (http://blog.izs.me/)",
+ "main": "lib/nopt.js",
+ "scripts": {
+ "preversion": "npm test",
+ "postversion": "npm publish",
+ "prepublishOnly": "git push origin --follow-tags",
+ "test": "tap test/*.js"
+ },
+ "repository": {
+ "type": "git",
+ "url": "https://github.com/npm/nopt.git"
+ },
+ "bin": {
+ "nopt": "bin/nopt.js"
+ },
+ "license": "ISC",
+ "dependencies": {
+ "abbrev": "1"
+ },
+ "devDependencies": {
+ "tap": "^14.10.6"
+ },
+ "files": [
+ "bin",
+ "lib"
+ ],
+ "engines": {
+ "node": ">=6"
+ }
+}
diff --git a/node_modules/nopt/bin/nopt.js b/node_modules/nopt/bin/nopt.js
index 3232d4c57..bb04291c6 100755
--- a/node_modules/nopt/bin/nopt.js
+++ b/node_modules/nopt/bin/nopt.js
@@ -1,54 +1,56 @@
#!/usr/bin/env node
-var nopt = require("../lib/nopt")
- , path = require("path")
- , types = { num: Number
- , bool: Boolean
- , help: Boolean
- , list: Array
- , "num-list": [Number, Array]
- , "str-list": [String, Array]
- , "bool-list": [Boolean, Array]
- , str: String
- , clear: Boolean
- , config: Boolean
- , length: Number
- , file: path
- }
- , shorthands = { s: [ "--str", "astring" ]
- , b: [ "--bool" ]
- , nb: [ "--no-bool" ]
- , tft: [ "--bool-list", "--no-bool-list", "--bool-list", "true" ]
- , "?": ["--help"]
- , h: ["--help"]
- , H: ["--help"]
- , n: [ "--num", "125" ]
- , c: ["--config"]
- , l: ["--length"]
- , f: ["--file"]
- }
- , parsed = nopt( types
- , shorthands
- , process.argv
- , 2 )
+var nopt = require('../lib/nopt')
+var path = require('path')
+var types = { num: Number,
+ bool: Boolean,
+ help: Boolean,
+ list: Array,
+ 'num-list': [Number, Array],
+ 'str-list': [String, Array],
+ 'bool-list': [Boolean, Array],
+ str: String,
+ clear: Boolean,
+ config: Boolean,
+ length: Number,
+ file: path,
+}
+var shorthands = { s: ['--str', 'astring'],
+ b: ['--bool'],
+ nb: ['--no-bool'],
+ tft: ['--bool-list', '--no-bool-list', '--bool-list', 'true'],
+ '?': ['--help'],
+ h: ['--help'],
+ H: ['--help'],
+ n: ['--num', '125'],
+ c: ['--config'],
+ l: ['--length'],
+ f: ['--file'],
+}
+var parsed = nopt(types
+ , shorthands
+ , process.argv
+ , 2)
-console.log("parsed", parsed)
+console.log('parsed', parsed)
if (parsed.help) {
- console.log("")
- console.log("nopt cli tester")
- console.log("")
- console.log("types")
+ console.log('')
+ console.log('nopt cli tester')
+ console.log('')
+ console.log('types')
console.log(Object.keys(types).map(function M (t) {
var type = types[t]
if (Array.isArray(type)) {
- return [t, type.map(function (type) { return type.name })]
+ return [t, type.map(function (mappedType) {
+ return mappedType.name
+ })]
}
return [t, type && type.name]
}).reduce(function (s, i) {
s[i[0]] = i[1]
return s
}, {}))
- console.log("")
- console.log("shorthands")
+ console.log('')
+ console.log('shorthands')
console.log(shorthands)
}
diff --git a/node_modules/nopt/lib/nopt.js b/node_modules/nopt/lib/nopt.js
index ecfa5da93..5829c2fe0 100644
--- a/node_modules/nopt/lib/nopt.js
+++ b/node_modules/nopt/lib/nopt.js
@@ -1,130 +1,147 @@
// info about each config option.
var debug = process.env.DEBUG_NOPT || process.env.NOPT_DEBUG
- ? function () { console.error.apply(console, arguments) }
+ ? function () {
+ console.error.apply(console, arguments)
+ }
: function () {}
-var url = require("url")
- , path = require("path")
- , Stream = require("stream").Stream
- , abbrev = require("abbrev")
- , os = require("os")
+var url = require('url')
+var path = require('path')
+var Stream = require('stream').Stream
+var abbrev = require('abbrev')
+var os = require('os')
module.exports = exports = nopt
exports.clean = clean
exports.typeDefs =
- { String : { type: String, validate: validateString }
- , Boolean : { type: Boolean, validate: validateBoolean }
- , url : { type: url, validate: validateUrl }
- , Number : { type: Number, validate: validateNumber }
- , path : { type: path, validate: validatePath }
- , Stream : { type: Stream, validate: validateStream }
- , Date : { type: Date, validate: validateDate }
+ { String: { type: String, validate: validateString },
+ Boolean: { type: Boolean, validate: validateBoolean },
+ url: { type: url, validate: validateUrl },
+ Number: { type: Number, validate: validateNumber },
+ path: { type: path, validate: validatePath },
+ Stream: { type: Stream, validate: validateStream },
+ Date: { type: Date, validate: validateDate },
}
function nopt (types, shorthands, args, slice) {
args = args || process.argv
types = types || {}
shorthands = shorthands || {}
- if (typeof slice !== "number") slice = 2
+ if (typeof slice !== 'number') {
+ slice = 2
+ }
debug(types, shorthands, args, slice)
args = args.slice(slice)
var data = {}
- , key
- , argv = {
- remain: [],
- cooked: args,
- original: args.slice(0)
- }
+ var argv = {
+ remain: [],
+ cooked: args,
+ original: args.slice(0),
+ }
parse(args, data, argv.remain, types, shorthands)
// now data is full
clean(data, types, exports.typeDefs)
data.argv = argv
Object.defineProperty(data.argv, 'toString', { value: function () {
- return this.original.map(JSON.stringify).join(" ")
- }, enumerable: false })
+ return this.original.map(JSON.stringify).join(' ')
+ },
+ enumerable: false })
return data
}
function clean (data, types, typeDefs) {
typeDefs = typeDefs || exports.typeDefs
var remove = {}
- , typeDefault = [false, true, null, String, Array]
+ var typeDefault = [false, true, null, String, Array]
Object.keys(data).forEach(function (k) {
- if (k === "argv") return
+ if (k === 'argv') {
+ return
+ }
var val = data[k]
- , isArray = Array.isArray(val)
- , type = types[k]
- if (!isArray) val = [val]
- if (!type) type = typeDefault
- if (type === Array) type = typeDefault.concat(Array)
- if (!Array.isArray(type)) type = [type]
-
- debug("val=%j", val)
- debug("types=", type)
- val = val.map(function (val) {
+ var isArray = Array.isArray(val)
+ var type = types[k]
+ if (!isArray) {
+ val = [val]
+ }
+ if (!type) {
+ type = typeDefault
+ }
+ if (type === Array) {
+ type = typeDefault.concat(Array)
+ }
+ if (!Array.isArray(type)) {
+ type = [type]
+ }
+
+ debug('val=%j', val)
+ debug('types=', type)
+ val = val.map(function (v) {
// if it's an unknown value, then parse false/true/null/numbers/dates
- if (typeof val === "string") {
- debug("string %j", val)
- val = val.trim()
- if ((val === "null" && ~type.indexOf(null))
- || (val === "true" &&
+ if (typeof v === 'string') {
+ debug('string %j', v)
+ v = v.trim()
+ if ((v === 'null' && ~type.indexOf(null))
+ || (v === 'true' &&
(~type.indexOf(true) || ~type.indexOf(Boolean)))
- || (val === "false" &&
+ || (v === 'false' &&
(~type.indexOf(false) || ~type.indexOf(Boolean)))) {
- val = JSON.parse(val)
- debug("jsonable %j", val)
- } else if (~type.indexOf(Number) && !isNaN(val)) {
- debug("convert to number", val)
- val = +val
- } else if (~type.indexOf(Date) && !isNaN(Date.parse(val))) {
- debug("convert to date", val)
- val = new Date(val)
+ v = JSON.parse(v)
+ debug('jsonable %j', v)
+ } else if (~type.indexOf(Number) && !isNaN(v)) {
+ debug('convert to number', v)
+ v = +v
+ } else if (~type.indexOf(Date) && !isNaN(Date.parse(v))) {
+ debug('convert to date', v)
+ v = new Date(v)
}
}
- if (!types.hasOwnProperty(k)) {
- return val
+ if (!Object.prototype.hasOwnProperty.call(types, k)) {
+ return v
}
// allow `--no-blah` to set 'blah' to null if null is allowed
- if (val === false && ~type.indexOf(null) &&
+ if (v === false && ~type.indexOf(null) &&
!(~type.indexOf(false) || ~type.indexOf(Boolean))) {
- val = null
+ v = null
}
var d = {}
- d[k] = val
- debug("prevalidated val", d, val, types[k])
- if (!validate(d, k, val, types[k], typeDefs)) {
+ d[k] = v
+ debug('prevalidated val', d, v, types[k])
+ if (!validate(d, k, v, types[k], typeDefs)) {
if (exports.invalidHandler) {
- exports.invalidHandler(k, val, types[k], data)
+ exports.invalidHandler(k, v, types[k], data)
} else if (exports.invalidHandler !== false) {
- debug("invalid: "+k+"="+val, types[k])
+ debug('invalid: ' + k + '=' + v, types[k])
}
return remove
}
- debug("validated val", d, val, types[k])
+ debug('validated v', d, v, types[k])
return d[k]
- }).filter(function (val) { return val !== remove })
+ }).filter(function (v) {
+ return v !== remove
+ })
// if we allow Array specifically, then an empty array is how we
// express 'no value here', not null. Allow it.
if (!val.length && type.indexOf(Array) === -1) {
debug('VAL HAS NO LENGTH, DELETE IT', val, k, type.indexOf(Array))
delete data[k]
- }
- else if (isArray) {
+ } else if (isArray) {
debug(isArray, data[k], val)
data[k] = val
- } else data[k] = val[0]
+ } else {
+ data[k] = val[0]
+ }
- debug("k=%s val=%j", k, val, data[k])
+ debug('k=%s val=%j', k, val, data[k])
})
}
@@ -133,17 +150,21 @@ function validateString (data, k, val) {
}
function validatePath (data, k, val) {
- if (val === true) return false
- if (val === null) return true
+ if (val === true) {
+ return false
+ }
+ if (val === null) {
+ return true
+ }
val = String(val)
- var isWin = process.platform === 'win32'
- , homePattern = isWin ? /^~(\/|\\)/ : /^~\//
- , home = os.homedir()
+ var isWin = process.platform === 'win32'
+ var homePattern = isWin ? /^~(\/|\\)/ : /^~\//
+ var home = os.homedir()
if (home && val.match(homePattern)) {
- data[k] = path.resolve(home, val.substr(2))
+ data[k] = path.resolve(home, val.slice(2))
} else {
data[k] = path.resolve(val)
}
@@ -151,63 +172,92 @@ function validatePath (data, k, val) {
}
function validateNumber (data, k, val) {
- debug("validate Number %j %j %j", k, val, isNaN(val))
- if (isNaN(val)) return false
+ debug('validate Number %j %j %j', k, val, isNaN(val))
+ if (isNaN(val)) {
+ return false
+ }
data[k] = +val
}
function validateDate (data, k, val) {
var s = Date.parse(val)
- debug("validate Date %j %j %j", k, val, s)
- if (isNaN(s)) return false
+ debug('validate Date %j %j %j', k, val, s)
+ if (isNaN(s)) {
+ return false
+ }
data[k] = new Date(val)
}
function validateBoolean (data, k, val) {
- if (val instanceof Boolean) val = val.valueOf()
- else if (typeof val === "string") {
- if (!isNaN(val)) val = !!(+val)
- else if (val === "null" || val === "false") val = false
- else val = true
- } else val = !!val
+ if (val instanceof Boolean) {
+ val = val.valueOf()
+ } else if (typeof val === 'string') {
+ if (!isNaN(val)) {
+ val = !!(+val)
+ } else if (val === 'null' || val === 'false') {
+ val = false
+ } else {
+ val = true
+ }
+ } else {
+ val = !!val
+ }
data[k] = val
}
function validateUrl (data, k, val) {
+ // Changing this would be a breaking change in the npm cli
+ /* eslint-disable-next-line node/no-deprecated-api */
val = url.parse(String(val))
- if (!val.host) return false
+ if (!val.host) {
+ return false
+ }
data[k] = val.href
}
function validateStream (data, k, val) {
- if (!(val instanceof Stream)) return false
+ if (!(val instanceof Stream)) {
+ return false
+ }
data[k] = val
}
function validate (data, k, val, type, typeDefs) {
// arrays are lists of types.
if (Array.isArray(type)) {
- for (var i = 0, l = type.length; i < l; i ++) {
- if (type[i] === Array) continue
- if (validate(data, k, val, type[i], typeDefs)) return true
+ for (let i = 0, l = type.length; i < l; i++) {
+ if (type[i] === Array) {
+ continue
+ }
+ if (validate(data, k, val, type[i], typeDefs)) {
+ return true
+ }
}
delete data[k]
return false
}
// an array of anything?
- if (type === Array) return true
+ if (type === Array) {
+ return true
+ }
+ // Original comment:
// NaN is poisonous. Means that something is not allowed.
+ // New comment: Changing this to an isNaN check breaks a lot of tests.
+ // Something is being assumed here that is not actually what happens in
+ // practice. Fixing it is outside the scope of getting linting to pass in
+ // this repo. Leaving as-is for now.
+ /* eslint-disable-next-line no-self-compare */
if (type !== type) {
- debug("Poison NaN", k, val, type)
+ debug('Poison NaN', k, val, type)
delete data[k]
return false
}
// explicit list of values
if (val === type) {
- debug("Explicitly allowed %j", val)
+ debug('Explicitly allowed %j', val)
// if (isArray) (data[k] = data[k] || []).push(val)
// else data[k] = val
data[k] = val
@@ -216,14 +266,17 @@ function validate (data, k, val, type, typeDefs) {
// now go through the list of typeDefs, validate against each one.
var ok = false
- , types = Object.keys(typeDefs)
- for (var i = 0, l = types.length; i < l; i ++) {
- debug("test type %j %j %j", k, val, types[i])
+ var types = Object.keys(typeDefs)
+ for (let i = 0, l = types.length; i < l; i++) {
+ debug('test type %j %j %j', k, val, types[i])
var t = typeDefs[types[i]]
- if (t &&
- ((type && type.name && t.type && t.type.name) ? (type.name === t.type.name) : (type === t.type))) {
+ if (t && (
+ (type && type.name && t.type && t.type.name) ?
+ (type.name === t.type.name) :
+ (type === t.type)
+ )) {
var d = {}
- ok = false !== t.validate(d, k, val)
+ ok = t.validate(d, k, val) !== false
val = d[k]
if (ok) {
// if (isArray) (data[k] = data[k] || []).push(val)
@@ -233,60 +286,63 @@ function validate (data, k, val, type, typeDefs) {
}
}
}
- debug("OK? %j (%j %j %j)", ok, k, val, types[i])
+ debug('OK? %j (%j %j %j)', ok, k, val, types[types.length - 1])
- if (!ok) delete data[k]
+ if (!ok) {
+ delete data[k]
+ }
return ok
}
function parse (args, data, remain, types, shorthands) {
- debug("parse", args, data, remain)
+ debug('parse', args, data, remain)
- var key = null
- , abbrevs = abbrev(Object.keys(types))
- , shortAbbr = abbrev(Object.keys(shorthands))
+ var abbrevs = abbrev(Object.keys(types))
+ var shortAbbr = abbrev(Object.keys(shorthands))
- for (var i = 0; i < args.length; i ++) {
+ for (var i = 0; i < args.length; i++) {
var arg = args[i]
- debug("arg", arg)
+ debug('arg', arg)
if (arg.match(/^-{2,}$/)) {
// done with keys.
// the rest are args.
remain.push.apply(remain, args.slice(i + 1))
- args[i] = "--"
+ args[i] = '--'
break
}
var hadEq = false
- if (arg.charAt(0) === "-" && arg.length > 1) {
+ if (arg.charAt(0) === '-' && arg.length > 1) {
var at = arg.indexOf('=')
if (at > -1) {
hadEq = true
- var v = arg.substr(at + 1)
- arg = arg.substr(0, at)
+ var v = arg.slice(at + 1)
+ arg = arg.slice(0, at)
args.splice(i, 1, arg, v)
}
// see if it's a shorthand
// if so, splice and back up to re-parse it.
var shRes = resolveShort(arg, shorthands, shortAbbr, abbrevs)
- debug("arg=%j shRes=%j", arg, shRes)
+ debug('arg=%j shRes=%j', arg, shRes)
if (shRes) {
debug(arg, shRes)
args.splice.apply(args, [i, 1].concat(shRes))
if (arg !== shRes[0]) {
- i --
+ i--
continue
}
}
- arg = arg.replace(/^-+/, "")
+ arg = arg.replace(/^-+/, '')
var no = null
- while (arg.toLowerCase().indexOf("no-") === 0) {
+ while (arg.toLowerCase().indexOf('no-') === 0) {
no = !no
- arg = arg.substr(3)
+ arg = arg.slice(3)
}
- if (abbrevs[arg]) arg = abbrevs[arg]
+ if (abbrevs[arg]) {
+ arg = abbrevs[arg]
+ }
var argType = types[arg]
var isTypeArray = Array.isArray(argType)
@@ -299,20 +355,24 @@ function parse (args, data, remain, types, shorthands) {
isTypeArray && argType.indexOf(Array) !== -1
// allow unknown things to be arrays if specified multiple times.
- if (!types.hasOwnProperty(arg) && data.hasOwnProperty(arg)) {
- if (!Array.isArray(data[arg]))
+ if (
+ !Object.prototype.hasOwnProperty.call(types, arg) &&
+ Object.prototype.hasOwnProperty.call(data, arg)
+ ) {
+ if (!Array.isArray(data[arg])) {
data[arg] = [data[arg]]
+ }
isArray = true
}
var val
- , la = args[i + 1]
+ var la = args[i + 1]
var isBool = typeof no === 'boolean' ||
argType === Boolean ||
isTypeArray && argType.indexOf(Boolean) !== -1 ||
(typeof argType === 'undefined' && !hadEq) ||
- (la === "false" &&
+ (la === 'false' &&
(argType === null ||
isTypeArray && ~argType.indexOf(null)))
@@ -320,11 +380,13 @@ function parse (args, data, remain, types, shorthands) {
// just set and move along
val = !no
// however, also support --bool true or --bool false
- if (la === "true" || la === "false") {
+ if (la === 'true' || la === 'false') {
val = JSON.parse(la)
la = null
- if (no) val = !val
- i ++
+ if (no) {
+ val = !val
+ }
+ i++
}
// also support "foo":[Boolean, "bar"] and "--foo bar"
@@ -332,49 +394,55 @@ function parse (args, data, remain, types, shorthands) {
if (~argType.indexOf(la)) {
// an explicit type
val = la
- i ++
- } else if ( la === "null" && ~argType.indexOf(null) ) {
+ i++
+ } else if (la === 'null' && ~argType.indexOf(null)) {
// null allowed
val = null
- i ++
- } else if ( !la.match(/^-{2,}[^-]/) &&
+ i++
+ } else if (!la.match(/^-{2,}[^-]/) &&
!isNaN(la) &&
- ~argType.indexOf(Number) ) {
+ ~argType.indexOf(Number)) {
// number
val = +la
- i ++
- } else if ( !la.match(/^-[^-]/) && ~argType.indexOf(String) ) {
+ i++
+ } else if (!la.match(/^-[^-]/) && ~argType.indexOf(String)) {
// string
val = la
- i ++
+ i++
}
}
- if (isArray) (data[arg] = data[arg] || []).push(val)
- else data[arg] = val
+ if (isArray) {
+ (data[arg] = data[arg] || []).push(val)
+ } else {
+ data[arg] = val
+ }
continue
}
if (argType === String) {
if (la === undefined) {
- la = ""
+ la = ''
} else if (la.match(/^-{1,2}[^-]+/)) {
- la = ""
- i --
+ la = ''
+ i--
}
}
if (la && la.match(/^-{2,}$/)) {
la = undefined
- i --
+ i--
}
val = la === undefined ? true : la
- if (isArray) (data[arg] = data[arg] || []).push(val)
- else data[arg] = val
+ if (isArray) {
+ (data[arg] = data[arg] || []).push(val)
+ } else {
+ data[arg] = val
+ }
- i ++
+ i++
continue
}
remain.push(arg)
@@ -389,14 +457,16 @@ function resolveShort (arg, shorthands, shortAbbr, abbrevs) {
arg = arg.replace(/^-+/, '')
// if it's an exact known option, then don't go any further
- if (abbrevs[arg] === arg)
+ if (abbrevs[arg] === arg) {
return null
+ }
// if it's an exact known shortopt, same deal
if (shorthands[arg]) {
// make it an array, if it's a list of words
- if (shorthands[arg] && !Array.isArray(shorthands[arg]))
+ if (shorthands[arg] && !Array.isArray(shorthands[arg])) {
shorthands[arg] = shorthands[arg].split(/\s+/)
+ }
return shorthands[arg]
}
@@ -406,7 +476,7 @@ function resolveShort (arg, shorthands, shortAbbr, abbrevs) {
if (!singles) {
singles = Object.keys(shorthands).filter(function (s) {
return s.length === 1
- }).reduce(function (l,r) {
+ }).reduce(function (l, r) {
l[r] = true
return l
}, {})
@@ -414,28 +484,32 @@ function resolveShort (arg, shorthands, shortAbbr, abbrevs) {
debug('shorthand singles', singles)
}
- var chrs = arg.split("").filter(function (c) {
+ var chrs = arg.split('').filter(function (c) {
return singles[c]
})
- if (chrs.join("") === arg) return chrs.map(function (c) {
- return shorthands[c]
- }).reduce(function (l, r) {
- return l.concat(r)
- }, [])
-
+ if (chrs.join('') === arg) {
+ return chrs.map(function (c) {
+ return shorthands[c]
+ }).reduce(function (l, r) {
+ return l.concat(r)
+ }, [])
+ }
// if it's an arg abbrev, and not a literal shorthand, then prefer the arg
- if (abbrevs[arg] && !shorthands[arg])
+ if (abbrevs[arg] && !shorthands[arg]) {
return null
+ }
// if it's an abbr for a shorthand, then use that
- if (shortAbbr[arg])
+ if (shortAbbr[arg]) {
arg = shortAbbr[arg]
+ }
// make it an array, if it's a list of words
- if (shorthands[arg] && !Array.isArray(shorthands[arg]))
+ if (shorthands[arg] && !Array.isArray(shorthands[arg])) {
shorthands[arg] = shorthands[arg].split(/\s+/)
+ }
return shorthands[arg]
}
diff --git a/node_modules/nopt/package.json b/node_modules/nopt/package.json
index 12ed02da5..a3cd13d8c 100644
--- a/node_modules/nopt/package.json
+++ b/node_modules/nopt/package.json
@@ -1,14 +1,20 @@
{
"name": "nopt",
- "version": "5.0.0",
+ "version": "6.0.0",
"description": "Option parsing for Node, supporting types, shorthands, etc. Used by npm.",
- "author": "Isaac Z. Schlueter <i@izs.me> (http://blog.izs.me/)",
+ "author": "GitHub Inc.",
"main": "lib/nopt.js",
"scripts": {
"preversion": "npm test",
"postversion": "npm publish",
"prepublishOnly": "git push origin --follow-tags",
- "test": "tap test/*.js"
+ "test": "tap",
+ "lint": "eslint \"**/*.js\"",
+ "postlint": "template-oss-check",
+ "template-oss-apply": "template-oss-apply --force",
+ "lintfix": "npm run lint -- --fix",
+ "snap": "tap",
+ "posttest": "npm run lint"
},
"repository": {
"type": "git",
@@ -19,16 +25,29 @@
},
"license": "ISC",
"dependencies": {
- "abbrev": "1"
+ "abbrev": "^1.0.0"
},
"devDependencies": {
- "tap": "^14.10.6"
+ "@npmcli/eslint-config": "^3.0.1",
+ "@npmcli/template-oss": "3.5.0",
+ "tap": "^16.3.0"
+ },
+ "tap": {
+ "lines": 87,
+ "functions": 91,
+ "branches": 81,
+ "statements": 87
},
"files": [
- "bin",
- "lib"
+ "bin/",
+ "lib/"
],
"engines": {
- "node": ">=6"
+ "node": "^12.13.0 || ^14.15.0 || >=16.0.0"
+ },
+ "templateOSS": {
+ "//@npmcli/template-oss": "This file is partially managed by @npmcli/template-oss. Edits may be overwritten.",
+ "windowsCI": false,
+ "version": "3.5.0"
}
}
diff --git a/package-lock.json b/package-lock.json
index d31e204eb..2dbdf0937 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -129,7 +129,7 @@
"mkdirp-infer-owner": "^2.0.0",
"ms": "^2.1.2",
"node-gyp": "^9.0.0",
- "nopt": "^5.0.0",
+ "nopt": "^6.0.0",
"npm-audit-report": "^3.0.0",
"npm-install-checks": "^5.0.0",
"npm-package-arg": "^9.1.0",
@@ -885,21 +885,6 @@
"node": "^12.13.0 || ^14.15.0 || >=16.0.0"
}
},
- "node_modules/@npmcli/config/node_modules/nopt": {
- "version": "6.0.0",
- "resolved": "https://registry.npmjs.org/nopt/-/nopt-6.0.0.tgz",
- "integrity": "sha512-ZwLpbTgdhuZUnZzjd7nb1ZV+4DoiC6/sfiVKok72ym/4Tlf+DFdlHYmT2JPmcNNWV6Pi3SDf1kT+A4r9RTuT9g==",
- "inBundle": true,
- "dependencies": {
- "abbrev": "^1.0.0"
- },
- "bin": {
- "nopt": "bin/nopt.js"
- },
- "engines": {
- "node": "^12.13.0 || ^14.15.0 || >=16.0.0"
- }
- },
"node_modules/@npmcli/disparity-colors": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/@npmcli/disparity-colors/-/disparity-colors-2.0.0.tgz",
@@ -5067,6 +5052,21 @@
"node": "*"
}
},
+ "node_modules/node-gyp/node_modules/nopt": {
+ "version": "5.0.0",
+ "resolved": "https://registry.npmjs.org/nopt/-/nopt-5.0.0.tgz",
+ "integrity": "sha512-Tbj67rffqceeLpcRXrT7vKAN8CwfPeIBgM7E6iBkmKLV7bEMwpGgYLGv0jACUsECaa/vuxP0IjEont6umdMgtQ==",
+ "inBundle": true,
+ "dependencies": {
+ "abbrev": "1"
+ },
+ "bin": {
+ "nopt": "bin/nopt.js"
+ },
+ "engines": {
+ "node": ">=6"
+ }
+ },
"node_modules/node-modules-regexp": {
"version": "1.0.0",
"dev": true,
@@ -5089,17 +5089,18 @@
}
},
"node_modules/nopt": {
- "version": "5.0.0",
+ "version": "6.0.0",
+ "resolved": "https://registry.npmjs.org/nopt/-/nopt-6.0.0.tgz",
+ "integrity": "sha512-ZwLpbTgdhuZUnZzjd7nb1ZV+4DoiC6/sfiVKok72ym/4Tlf+DFdlHYmT2JPmcNNWV6Pi3SDf1kT+A4r9RTuT9g==",
"inBundle": true,
- "license": "ISC",
"dependencies": {
- "abbrev": "1"
+ "abbrev": "^1.0.0"
},
"bin": {
"nopt": "bin/nopt.js"
},
"engines": {
- "node": ">=6"
+ "node": "^12.13.0 || ^14.15.0 || >=16.0.0"
}
},
"node_modules/normalize-package-data": {
@@ -10068,7 +10069,7 @@
"minimatch": "^5.1.0",
"mkdirp": "^1.0.4",
"mkdirp-infer-owner": "^2.0.0",
- "nopt": "^5.0.0",
+ "nopt": "^6.0.0",
"npm-install-checks": "^5.0.0",
"npm-package-arg": "^9.0.0",
"npm-pick-manifest": "^7.0.0",
diff --git a/package.json b/package.json
index 5f345a43e..4fda192af 100644
--- a/package.json
+++ b/package.json
@@ -97,7 +97,7 @@
"mkdirp-infer-owner": "^2.0.0",
"ms": "^2.1.2",
"node-gyp": "^9.0.0",
- "nopt": "^5.0.0",
+ "nopt": "^6.0.0",
"npm-audit-report": "^3.0.0",
"npm-install-checks": "^5.0.0",
"npm-package-arg": "^9.1.0",
diff --git a/workspaces/arborist/package.json b/workspaces/arborist/package.json
index 7bfb90a07..98b183091 100644
--- a/workspaces/arborist/package.json
+++ b/workspaces/arborist/package.json
@@ -21,7 +21,7 @@
"minimatch": "^5.1.0",
"mkdirp": "^1.0.4",
"mkdirp-infer-owner": "^2.0.0",
- "nopt": "^5.0.0",
+ "nopt": "^6.0.0",
"npm-install-checks": "^5.0.0",
"npm-package-arg": "^9.0.0",
"npm-pick-manifest": "^7.0.0",