Comparing version 17.4.0 to 17.4.1
@@ -336,5 +336,5 @@ import { assertNotStrictEqual, } from './typings/common-types.js'; | ||
positionalMap[key] = parsed.argv[key]; | ||
if (!Object.prototype.hasOwnProperty.call(defaults, key) && | ||
Object.prototype.hasOwnProperty.call(argv, key) && | ||
Object.prototype.hasOwnProperty.call(parsed.argv, key) && | ||
if (!Object.hasOwnProperty.call(defaults, key) && | ||
Object.hasOwnProperty.call(argv, key) && | ||
Object.hasOwnProperty.call(parsed.argv, key) && | ||
(Array.isArray(argv[key]) || Array.isArray(parsed.argv[key]))) { | ||
@@ -341,0 +341,0 @@ argv[key] = [].concat(argv[key], parsed.argv[key]); |
@@ -72,2 +72,3 @@ import { isCommandBuilderCallback } from './command.js'; | ||
if (!isPositionalKey && | ||
!options.hiddenOptions.includes(key) && | ||
!this.argsContainKey(args, argv, key, negable)) { | ||
@@ -85,3 +86,3 @@ this.completeOptionKey(key, completions, current); | ||
if (choices && choices.length > 0) { | ||
completions.push(...choices); | ||
completions.push(...choices.map(c => c.replace(/:/g, '\\:'))); | ||
} | ||
@@ -91,7 +92,11 @@ } | ||
choicesFromPositionalsCompletions(completions, args, argv, current) { | ||
if (current === '' && | ||
completions.length > 0 && | ||
this.previousArgHasChoices(args)) { | ||
return; | ||
} | ||
const positionalKeys = this.yargs.getGroups()[this.usage.getPositionalGroupName()] || []; | ||
const offset = Math.max(this.indexAfterLastReset, this.yargs.getInternalMethods().getContext().commands.length + | ||
1); | ||
const positionalValues = argv._.slice(offset); | ||
const positionalKey = positionalKeys[positionalValues.length - 1]; | ||
const positionalKey = positionalKeys[argv._.length - offset - 1]; | ||
if (!positionalKey) { | ||
@@ -103,3 +108,3 @@ return; | ||
if (choice.startsWith(current)) { | ||
completions.push(choice); | ||
completions.push(choice.replace(/:/g, '\\:')); | ||
} | ||
@@ -106,0 +111,0 @@ } |
@@ -15,8 +15,9 @@ import { objFilter } from './utils/obj-filter.js'; | ||
let failMessage = null; | ||
let globalFailMessage = null; | ||
let showHelpOnFail = true; | ||
self.showHelpOnFail = function showHelpOnFailFn(arg1 = true, arg2) { | ||
function parseFunctionArgs() { | ||
return typeof arg1 === 'string' ? [true, arg1] : [arg1, arg2]; | ||
const [enabled, message] = typeof arg1 === 'string' ? [true, arg1] : [arg1, arg2]; | ||
if (yargs.getInternalMethods().isGlobalContext()) { | ||
globalFailMessage = message; | ||
} | ||
const [enabled, message] = parseFunctionArgs(); | ||
failMessage = message; | ||
@@ -54,6 +55,7 @@ showHelpOnFail = enabled; | ||
logger.error(msg || err); | ||
if (failMessage) { | ||
const globalOrCommandFailMessage = failMessage || globalFailMessage; | ||
if (globalOrCommandFailMessage) { | ||
if (msg || err) | ||
logger.error(''); | ||
logger.error(failMessage); | ||
logger.error(globalOrCommandFailMessage); | ||
} | ||
@@ -60,0 +62,0 @@ } |
{ | ||
"name": "yargs", | ||
"version": "17.4.0", | ||
"version": "17.4.1", | ||
"description": "yargs the modern, pirate-themed, successor to optimist.", | ||
@@ -5,0 +5,0 @@ "main": "./index.cjs", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
284791
5149