Socket
Socket
Sign inDemoInstall

yargs

Package Overview
Dependencies
15
Maintainers
2
Versions
250
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 17.0.0-candidate.8 to 17.0.0-candidate.9

build/lib/argsert.d.ts

46

build/lib/command.js

@@ -118,3 +118,3 @@ import { assertNotStrictEqual, } from './typings/common-types.js';

this.defaultCommand;
const currentContext = yargs.getContext();
const currentContext = yargs.getInternalMethods().getContext();
const parentCommands = currentContext.commands.slice();

@@ -139,3 +139,3 @@ if (command) {

if (isCommandBuilderCallback(builder)) {
const builderOutput = builder(yargs.reset(aliases), helpOrVersionSet);
const builderOutput = builder(yargs.getInternalMethods().reset(aliases), helpOrVersionSet);
if (isPromise(builderOutput)) {

@@ -149,3 +149,3 @@ return builderOutput.then(output => {

else if (isCommandBuilderOptionDefinitions(builder)) {
innerYargs = yargs.reset(aliases);
innerYargs = yargs.getInternalMethods().reset(aliases);
Object.keys(commandHandler.builder).forEach(key => {

@@ -159,9 +159,12 @@ innerYargs.option(key, builder[key]);

if (!command)
innerYargs.getUsageInstance().unfreeze();
innerYargs.getInternalMethods().getUsageInstance().unfreeze();
if (this.shouldUpdateUsage(innerYargs)) {
innerYargs
.getInternalMethods()
.getUsageInstance()
.usage(this.usageFromParentCommandsCommandHandler(parentCommands, commandHandler), commandHandler.description);
}
const innerArgv = innerYargs._parseArgs(null, undefined, true, commandIndex, helpOnly);
const innerArgv = innerYargs
.getInternalMethods()
.runYargsParserAndExecuteCommands(null, undefined, true, commandIndex, helpOnly);
return {

@@ -173,4 +176,4 @@ aliases: innerYargs.parsed.aliases,

shouldUpdateUsage(yargs) {
return (!yargs.getUsageInstance().getUsageDisabled() &&
yargs.getUsageInstance().getUsage().length === 0);
return (!yargs.getInternalMethods().getUsageInstance().getUsageDisabled() &&
yargs.getInternalMethods().getUsageInstance().getUsage().length === 0);
}

@@ -191,3 +194,3 @@ usageFromParentCommandsCommandHandler(parentCommands, commandHandler) {

return innerArgv;
if (!yargs._hasOutput()) {
if (!yargs.getInternalMethods().getHasOutput()) {
positionalMap = this.populatePositionals(commandHandler, innerArgv, currentContext, yargs);

@@ -200,4 +203,6 @@ }

innerArgv = applyMiddleware(innerArgv, yargs, middlewares, true);
if (!yargs._hasOutput()) {
const validation = yargs._runValidation(aliases, positionalMap, yargs.parsed.error, !command);
if (!yargs.getInternalMethods().getHasOutput()) {
const validation = yargs
.getInternalMethods()
.runValidation(aliases, positionalMap, yargs.parsed.error, !command);
innerArgv = maybeAsyncResult(innerArgv, result => {

@@ -208,6 +213,8 @@ validation(result);

}
if (commandHandler.handler && !yargs._hasOutput()) {
yargs._setHasOutput();
if (commandHandler.handler && !yargs.getInternalMethods().getHasOutput()) {
yargs.getInternalMethods().setHasOutput();
const populateDoubleDash = !!yargs.getOptions().configuration['populate--'];
yargs._postProcess(innerArgv, populateDoubleDash, false, false);
yargs
.getInternalMethods()
.postProcess(innerArgv, populateDoubleDash, false, false);
innerArgv = applyMiddleware(innerArgv, yargs, middlewares, false);

@@ -223,7 +230,8 @@ innerArgv = maybeAsyncResult(innerArgv, result => {

});
yargs.getUsageInstance().cacheHelpMessage();
if (isPromise(innerArgv) && !yargs._hasParseCallback()) {
yargs.getInternalMethods().getUsageInstance().cacheHelpMessage();
if (isPromise(innerArgv) &&
!yargs.getInternalMethods().hasParseCallback()) {
innerArgv.catch(error => {
try {
yargs.getUsageInstance().fail(null, error);
yargs.getInternalMethods().getUsageInstance().fail(null, error);
}

@@ -322,3 +330,6 @@ catch (_err) {

if (parsed.error) {
yargs.getUsageInstance().fail(parsed.error.message, parsed.error);
yargs
.getInternalMethods()
.getUsageInstance()
.fail(parsed.error.message, parsed.error);
}

@@ -347,2 +358,3 @@ else {

yargs
.getInternalMethods()
.getUsageInstance()

@@ -349,0 +361,0 @@ .usage(commandString, this.defaultCommand.description);

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

this.customCompletionFunction = null;
this.zshShell = (_c = (((_a = this.shim.getEnv('SHELL')) === null || _a === void 0 ? void 0 : _a.includes('zsh')) || ((_b = this.shim.getEnv('ZSH_NAME')) === null || _b === void 0 ? void 0 : _b.includes('zsh')))) !== null && _c !== void 0 ? _c : false;
this.zshShell =
(_c = (((_a = this.shim.getEnv('SHELL')) === null || _a === void 0 ? void 0 : _a.includes('zsh')) ||
((_b = this.shim.getEnv('ZSH_NAME')) === null || _b === void 0 ? void 0 : _b.includes('zsh')))) !== null && _c !== void 0 ? _c : false;
}

@@ -25,3 +27,3 @@ defaultCompletion(args, argv, current, done) {

if (isCommandBuilderCallback(builder)) {
const y = this.yargs.reset();
const y = this.yargs.getInternalMethods().reset();
builder(y, true);

@@ -38,3 +40,4 @@ return y.argv;

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

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

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

}
export function usage(yargs, y18n, shim) {
const __ = y18n.__;
export function usage(yargs, shim) {
const __ = shim.y18n.__;
const self = {};

@@ -28,3 +28,3 @@ const fails = [];

self.fail = function fail(msg, err) {
const logger = yargs._getLoggerInstance();
const logger = yargs.getInternalMethods().getLoggerInstance();
if (fails.length) {

@@ -65,3 +65,3 @@ for (let i = fails.length - 1; i >= 0; --i) {

}
else if (yargs._hasParseCallback()) {
else if (yargs.getInternalMethods().hasParseCallback()) {
return yargs.exit(1, err);

@@ -197,7 +197,8 @@ }

ui.div(__('Commands:'));
const context = yargs.getContext();
const context = yargs.getInternalMethods().getContext();
const parentCommands = context.commands.length
? `${context.commands.join(' ')} `
: '';
if (yargs.getParserConfiguration()['sort-commands'] === true) {
if (yargs.getInternalMethods().getParserConfiguration()['sort-commands'] ===
true) {
commands = commands.sort((a, b) => a[0].localeCompare(b[0]));

@@ -450,3 +451,3 @@ }

self.showHelp = (level) => {
const logger = yargs._getLoggerInstance();
const logger = yargs.getInternalMethods().getLoggerInstance();
if (!level)

@@ -511,3 +512,3 @@ level = 'error';

self.showVersion = level => {
const logger = yargs._getLoggerInstance();
const logger = yargs.getInternalMethods().getLoggerInstance();
if (!level)

@@ -514,0 +515,0 @@ level = 'error';

@@ -6,5 +6,5 @@ import { argsert } from './argsert.js';

const specialKeys = ['$0', '--', '_'];
export function validation(yargs, usage, y18n, shim) {
const __ = y18n.__;
const __n = y18n.__n;
export function validation(yargs, usage, shim) {
const __ = shim.y18n.__;
const __n = shim.y18n.__n;
const self = {};

@@ -14,3 +14,3 @@ self.nonOptionCount = function nonOptionCount(argv) {

const positionalCount = argv._.length + (argv['--'] ? argv['--'].length : 0);
const _s = positionalCount - yargs.getContext().commands.length;
const _s = positionalCount - yargs.getInternalMethods().getContext().commands.length;
if (demandedCommands._ &&

@@ -71,9 +71,12 @@ (_s < demandedCommands._.min || _s > demandedCommands._.max)) {

self.unknownArguments = function unknownArguments(argv, aliases, positionalMap, isDefaultCommand, checkPositionals = true) {
const commandKeys = yargs.getCommandInstance().getCommands();
const commandKeys = yargs
.getInternalMethods()
.getCommandInstance()
.getCommands();
const unknown = [];
const currentContext = yargs.getContext();
const currentContext = yargs.getInternalMethods().getContext();
Object.keys(argv).forEach(key => {
if (specialKeys.indexOf(key) === -1 &&
!Object.prototype.hasOwnProperty.call(positionalMap, key) &&
!Object.prototype.hasOwnProperty.call(yargs._getParseContext(), key) &&
!Object.prototype.hasOwnProperty.call(yargs.getInternalMethods().getParseContext(), key) &&
!self.isValidAndSomeAliasIsNotNew(key, aliases)) {

@@ -98,5 +101,8 @@ unknown.push(key);

self.unknownCommands = function unknownCommands(argv) {
const commandKeys = yargs.getCommandInstance().getCommands();
const commandKeys = yargs
.getInternalMethods()
.getCommandInstance()
.getCommands();
const unknown = [];
const currentContext = yargs.getContext();
const currentContext = yargs.getInternalMethods().getContext();
if (currentContext.commands.length > 0 || commandKeys.length > 0) {

@@ -103,0 +109,0 @@ argv._.slice(currentContext.commands.length).forEach(key => {

{
"name": "yargs",
"version": "17.0.0-candidate.8",
"version": "17.0.0-candidate.9",
"description": "yargs the modern, pirate-themed, successor to optimist.",

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

"@wessberg/rollup-plugin-ts": "^1.3.2",
"c8": "^7.0.0",
"c8": "^7.7.0",
"chai": "^4.2.0",

@@ -69,2 +69,3 @@ "chalk": "^4.0.0",

"cross-spawn": "^7.0.0",
"eslint": "^7.23.0",
"gts": "^3.0.0",

@@ -71,0 +72,0 @@ "hashish": "0.0.4",

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc