mirror of
https://github.com/actions/labeler.git
synced 2025-12-19 00:26:47 +00:00
build
This commit is contained in:
45
node_modules/yargs/yargs.js
generated
vendored
45
node_modules/yargs/yargs.js
generated
vendored
@@ -11,7 +11,7 @@ const Y18n = require('y18n')
|
||||
const objFilter = require('./lib/obj-filter')
|
||||
const setBlocking = require('set-blocking')
|
||||
const applyExtends = require('./lib/apply-extends')
|
||||
const middlewareFactory = require('./lib/middleware')
|
||||
const { globalMiddlewareFactory } = require('./lib/middleware')
|
||||
const YError = require('./lib/yerror')
|
||||
|
||||
exports = module.exports = Yargs
|
||||
@@ -33,7 +33,7 @@ function Yargs (processArgs, cwd, parentRequire) {
|
||||
updateFiles: false
|
||||
})
|
||||
|
||||
self.middleware = middlewareFactory(globalMiddleware, self)
|
||||
self.middleware = globalMiddlewareFactory(globalMiddleware, self)
|
||||
|
||||
if (!cwd) cwd = process.cwd()
|
||||
|
||||
@@ -231,6 +231,7 @@ function Yargs (processArgs, cwd, parentRequire) {
|
||||
function populateParserHintArray (type, keys, value) {
|
||||
keys = [].concat(keys)
|
||||
keys.forEach((key) => {
|
||||
key = sanitizeKey(key)
|
||||
options[type].push(key)
|
||||
})
|
||||
}
|
||||
@@ -286,8 +287,8 @@ function Yargs (processArgs, cwd, parentRequire) {
|
||||
|
||||
function populateParserHintObject (builder, isArray, type, key, value) {
|
||||
if (Array.isArray(key)) {
|
||||
const temp = Object.create(null)
|
||||
// an array of keys with one value ['x', 'y', 'z'], function parse () {}
|
||||
const temp = {}
|
||||
key.forEach((k) => {
|
||||
temp[k] = value
|
||||
})
|
||||
@@ -298,6 +299,7 @@ function Yargs (processArgs, cwd, parentRequire) {
|
||||
builder(k, key[k])
|
||||
})
|
||||
} else {
|
||||
key = sanitizeKey(key)
|
||||
// a single key value pair 'x', parse() {}
|
||||
if (isArray) {
|
||||
options[type][key] = (options[type][key] || []).concat(value)
|
||||
@@ -307,6 +309,13 @@ function Yargs (processArgs, cwd, parentRequire) {
|
||||
}
|
||||
}
|
||||
|
||||
// TODO(bcoe): in future major versions move more objects towards
|
||||
// Object.create(null):
|
||||
function sanitizeKey (key) {
|
||||
if (key === '__proto__') return '___proto___'
|
||||
return key
|
||||
}
|
||||
|
||||
function deleteFromParserHintObject (optionKey) {
|
||||
// delete from all parsing hints:
|
||||
// boolean, array, key, alias, etc.
|
||||
@@ -694,8 +703,8 @@ function Yargs (processArgs, cwd, parentRequire) {
|
||||
}
|
||||
|
||||
// .positional() only supports a subset of the configuration
|
||||
// options availble to .option().
|
||||
const supportedOpts = ['default', 'implies', 'normalize',
|
||||
// options available to .option().
|
||||
const supportedOpts = ['default', 'defaultDescription', 'implies', 'normalize',
|
||||
'choices', 'conflicts', 'coerce', 'type', 'describe',
|
||||
'desc', 'description', 'alias']
|
||||
opts = objFilter(opts, (k, v) => {
|
||||
@@ -765,6 +774,14 @@ function Yargs (processArgs, cwd, parentRequire) {
|
||||
}
|
||||
self.getStrict = () => strict
|
||||
|
||||
let parserConfig = {}
|
||||
self.parserConfiguration = function parserConfiguration (config) {
|
||||
argsert('<object>', [config], arguments.length)
|
||||
parserConfig = config
|
||||
return self
|
||||
}
|
||||
self.getParserConfiguration = () => parserConfig
|
||||
|
||||
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.
|
||||
@@ -895,7 +912,7 @@ function Yargs (processArgs, cwd, parentRequire) {
|
||||
// register the completion command.
|
||||
completionCommand = cmd || 'completion'
|
||||
if (!desc && desc !== false) {
|
||||
desc = 'generate bash completion script'
|
||||
desc = 'generate completion script'
|
||||
}
|
||||
self.command(completionCommand, desc)
|
||||
|
||||
@@ -1010,7 +1027,14 @@ function Yargs (processArgs, cwd, parentRequire) {
|
||||
args = args || processArgs
|
||||
|
||||
options.__ = y18n.__
|
||||
options.configuration = pkgUp()['yargs'] || {}
|
||||
options.configuration = self.getParserConfiguration()
|
||||
|
||||
// Deprecated
|
||||
let pkgConfig = pkgUp()['yargs']
|
||||
if (pkgConfig) {
|
||||
console.warn('Configuring yargs through package.json is deprecated and will be removed in the next major release, please use the JS API instead.')
|
||||
options.configuration = Object.assign({}, pkgConfig, options.configuration)
|
||||
}
|
||||
|
||||
const parsed = Parser.detailed(args, options)
|
||||
let argv = parsed.argv
|
||||
@@ -1152,7 +1176,7 @@ function Yargs (processArgs, cwd, parentRequire) {
|
||||
}
|
||||
|
||||
self._runValidation = function runValidation (argv, aliases, positionalMap, parseErrors) {
|
||||
if (parseErrors) throw new YError(parseErrors.message)
|
||||
if (parseErrors) throw new YError(parseErrors.message || parseErrors)
|
||||
validation.nonOptionCount(argv)
|
||||
validation.requiredArguments(argv)
|
||||
if (strict) validation.unknownArguments(argv, aliases, positionalMap)
|
||||
@@ -1166,8 +1190,9 @@ function Yargs (processArgs, cwd, parentRequire) {
|
||||
if (!detectLocale) return
|
||||
|
||||
try {
|
||||
const osLocale = require('os-locale')
|
||||
self.locale(osLocale.sync({ spawn: false }))
|
||||
const { env } = process
|
||||
const locale = env.LC_ALL || env.LC_MESSAGES || env.LANG || env.LANGUAGE || 'en_US'
|
||||
self.locale(locale.replace(/[.:].*/, ''))
|
||||
} catch (err) {
|
||||
// if we explode looking up locale just noop
|
||||
// we'll keep using the default language 'en'.
|
||||
|
||||
Reference in New Issue
Block a user