Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

yargs

Package Overview
Dependencies
Maintainers
2
Versions
250
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

yargs - npm Package Compare versions

Comparing version 17.0.1 to 17.0.2-candidate

28

build/lib/command.js

@@ -167,16 +167,11 @@ import { assertNotStrictEqual, } from './typings/common-types.js';

.runYargsParserAndExecuteCommands(null, undefined, true, commandIndex, helpOnly);
if (isPromise(innerArgv)) {
return innerArgv.then(argv => {
return {
aliases: innerYargs.parsed.aliases,
innerArgv: argv,
};
});
}
else {
return {
return isPromise(innerArgv)
? innerArgv.then(argv => ({
aliases: innerYargs.parsed.aliases,
innerArgv: argv,
}))
: {
aliases: innerYargs.parsed.aliases,
innerArgv: innerArgv,
};
}
}

@@ -227,8 +222,5 @@ shouldUpdateUsage(yargs) {

const handlerResult = commandHandler.handler(result);
if (isPromise(handlerResult)) {
return handlerResult.then(() => result);
}
else {
return result;
}
return isPromise(handlerResult)
? handlerResult.then(() => result)
: result;
});

@@ -347,3 +339,3 @@ if (!isDefaultCommand) {

Object.keys(parsed.argv).forEach(key => {
if (positionalKeys.indexOf(key) !== -1) {
if (positionalKeys.includes(key)) {
if (!positionalMap[key])

@@ -350,0 +342,0 @@ positionalMap[key] = parsed.argv[key];

@@ -38,4 +38,5 @@ import { isCommandBuilderCallback } from './command.js';

commandCompletions(completions, args, current) {
const parentCommands = this.yargs.getInternalMethods().getContext()
.commands;
const parentCommands = this.yargs
.getInternalMethods()
.getContext().commands;
if (!current.match(/^-/) &&

@@ -42,0 +43,0 @@ parentCommands[parentCommands.length - 1] !== current) {

@@ -250,6 +250,6 @@ import { objFilter } from './utils/obj-filter.js';

.map(key => {
if (~aliasKeys.indexOf(key))
if (aliasKeys.includes(key))
return key;
for (let i = 0, aliasKey; (aliasKey = aliasKeys[i]) !== undefined; i++) {
if (~(options.alias[aliasKey] || []).indexOf(key))
if ((options.alias[aliasKey] || []).includes(key))
return aliasKey;

@@ -271,3 +271,3 @@ }

return ((/^[0-9]$/.test(sw)
? ~options.boolean.indexOf(key)
? options.boolean.includes(key)
? '-'

@@ -310,15 +310,15 @@ : '--'

let type = null;
if (~desc.lastIndexOf(deferY18nLookupPrefix))
if (desc.includes(deferY18nLookupPrefix))
desc = __(desc.substring(deferY18nLookupPrefix.length));
if (~options.boolean.indexOf(key))
if (options.boolean.includes(key))
type = `[${__('boolean')}]`;
if (~options.count.indexOf(key))
if (options.count.includes(key))
type = `[${__('count')}]`;
if (~options.string.indexOf(key))
if (options.string.includes(key))
type = `[${__('string')}]`;
if (~options.normalize.indexOf(key))
if (options.normalize.includes(key))
type = `[${__('string')}]`;
if (~options.array.indexOf(key))
if (options.array.includes(key))
type = `[${__('array')}]`;
if (~options.number.indexOf(key))
if (options.number.includes(key))
type = `[${__('number')}]`;

@@ -406,13 +406,13 @@ const deprecatedExtra = (deprecated) => typeof deprecated === 'string'

yargs.demandOption(key, demandedOptions[alias]);
if (~options.boolean.indexOf(alias))
if (options.boolean.includes(alias))
yargs.boolean(key);
if (~options.count.indexOf(alias))
if (options.count.includes(alias))
yargs.count(key);
if (~options.string.indexOf(alias))
if (options.string.includes(alias))
yargs.string(key);
if (~options.normalize.indexOf(alias))
if (options.normalize.includes(alias))
yargs.normalize(key);
if (~options.array.indexOf(alias))
if (options.array.includes(alias))
yargs.array(key);
if (~options.number.indexOf(alias))
if (options.number.includes(alias))
yargs.number(key);

@@ -419,0 +419,0 @@ });

@@ -69,2 +69,3 @@ import { argsert } from './argsert.js';

self.unknownArguments = function unknownArguments(argv, aliases, positionalMap, isDefaultCommand, checkPositionals = true) {
var _a;
const commandKeys = yargs

@@ -77,3 +78,3 @@ .getInternalMethods()

Object.keys(argv).forEach(key => {
if (specialKeys.indexOf(key) === -1 &&
if (!specialKeys.includes(key) &&
!Object.prototype.hasOwnProperty.call(positionalMap, key) &&

@@ -90,3 +91,3 @@ !Object.prototype.hasOwnProperty.call(yargs.getInternalMethods().getParseContext(), key) &&

argv._.slice(currentContext.commands.length).forEach(key => {
if (commandKeys.indexOf('' + key) === -1) {
if (!commandKeys.includes('' + key)) {
unknown.push('' + key);

@@ -96,3 +97,17 @@ }

}
if (unknown.length > 0) {
if (checkPositionals) {
const demandedCommands = yargs.getDemandedCommands();
const maxNonOptDemanded = ((_a = demandedCommands._) === null || _a === void 0 ? void 0 : _a.max) || 0;
const expected = currentContext.commands.length + maxNonOptDemanded;
if (expected < argv._.length) {
argv._.slice(expected).forEach(key => {
key = String(key);
if (!currentContext.commands.includes(key) &&
!unknown.includes(key)) {
unknown.push(key);
}
});
}
}
if (unknown.length) {
usage.fail(__n('Unknown argument: %s', 'Unknown arguments: %s', unknown.length, unknown.join(', ')));

@@ -110,3 +125,3 @@ }

argv._.slice(currentContext.commands.length).forEach(key => {
if (commandKeys.indexOf('' + key) === -1) {
if (!commandKeys.includes('' + key)) {
unknown.push('' + key);

@@ -113,0 +128,0 @@ }

{
"Commands:": "命令:",
"Options:": "選項:",
"Examples:": "例:",
"boolean": "布林",
"count": "次數",
"string": "字串",
"number": "數字",
"array": "陣列",
"required": "必須",
"default": "預設值",
"default:": "預設值:",
"choices:": "可選值:",
"aliases:": "別名:",
"generated-value": "生成的值",
"Not enough non-option arguments: got %s, need at least %s": {
"one": "non-option 引數不足:只傳入了 %s 個, 至少要 %s 個",
"other": "non-option 引數不足:只傳入了 %s 個, 至少要 %s 個"
},
"Too many non-option arguments: got %s, maximum of %s": {
"one": "non-option 引數過多:傳入了 %s 個, 但最多 %s 個",
"other": "non-option 引數過多:傳入了 %s 個, 但最多 %s 個"
},
"Missing argument value: %s": {
"one": "此引數無指定值:%s",
"other": "這些引數無指定值:%s"
},
"Missing required argument: %s": {
"one": "缺少必須的引數:%s",
"other": "缺少這些必須的引數:%s"
},
"Unknown argument: %s": {
"one": "未知的引數:%s",
"other": "未知的這些引數:%s"
},
"Invalid values:": "無效的選項值:",
"Argument: %s, Given: %s, Choices: %s": "引數名稱: %s, 傳入的值: %s, 可選的值:%s",
"Argument check failed: %s": "引數驗證失敗:%s",
"Implications failed:": "缺少依賴的選項:",
"Not enough arguments following: %s": "沒有提供足夠的值給此引數:%s",
"Invalid JSON config file: %s": "無效的 JSON 設置文件:%s",
"Path to JSON config file": "JSON 設置文件的路徑",
"Show help": "顯示說明",
"Show version number": "顯示版本",
"Did you mean %s?": "是指 %s?",
"Arguments %s and %s are mutually exclusive" : "引數 %s 和 %s 是互斥的"
}
"Commands:": "命令:",
"Options:": "選項:",
"Examples:": "範例:",
"boolean": "布林",
"count": "次數",
"string": "字串",
"number": "數字",
"array": "陣列",
"required": "必填",
"default": "預設值",
"default:": "預設值:",
"choices:": "可選值:",
"aliases:": "別名:",
"generated-value": "生成的值",
"Not enough non-option arguments: got %s, need at least %s": {
"one": "non-option 引數不足:只傳入了 %s 個, 至少要 %s 個",
"other": "non-option 引數不足:只傳入了 %s 個, 至少要 %s 個"
},
"Too many non-option arguments: got %s, maximum of %s": {
"one": "non-option 引數過多:傳入了 %s 個, 但最多 %s 個",
"other": "non-option 引數過多:傳入了 %s 個, 但最多 %s 個"
},
"Missing argument value: %s": {
"one": "此引數無指定值:%s",
"other": "這些引數無指定值:%s"
},
"Missing required argument: %s": {
"one": "缺少必須的引數:%s",
"other": "缺少這些必須的引數:%s"
},
"Unknown argument: %s": {
"one": "未知的引數:%s",
"other": "未知的引數:%s"
},
"Invalid values:": "無效的選項值:",
"Argument: %s, Given: %s, Choices: %s": "引數名稱: %s, 傳入的值: %s, 可選的值:%s",
"Argument check failed: %s": "引數驗證失敗:%s",
"Implications failed:": "缺少依賴引數:",
"Not enough arguments following: %s": "沒有提供足夠的值給此引數:%s",
"Invalid JSON config file: %s": "無效的 JSON 設置文件:%s",
"Path to JSON config file": "JSON 設置文件的路徑",
"Show help": "顯示說明",
"Show version number": "顯示版本",
"Did you mean %s?": "您是指 %s 嗎?",
"Arguments %s and %s are mutually exclusive" : "引數 %s 和 %s 互斥",
"Positionals:": "位置:",
"command": "命令",
"deprecated": "已淘汰",
"deprecated: %s": "已淘汰:%s"
}
{
"name": "yargs",
"version": "17.0.1",
"version": "17.0.2-candidate",
"description": "yargs the modern, pirate-themed, successor to optimist.",

@@ -72,3 +72,3 @@ "main": "./index.cjs",

"hashish": "0.0.4",
"mocha": "^8.0.0",
"mocha": "^9.0.0",
"rimraf": "^3.0.2",

@@ -75,0 +75,0 @@ "rollup": "^2.23.0",

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc