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

commander

Package Overview
Dependencies
Maintainers
6
Versions
115
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

commander - npm Package Compare versions

Comparing version 4.0.0 to 4.0.1

24

CHANGELOG.md

@@ -10,2 +10,8 @@ # Changelog

## [4.0.1] (2019-11-12)
### Fixed
* display help when requested, even if there are missing required options [(#1091)]
## [4.0.0] (2019-11-02)

@@ -36,2 +42,18 @@

### Migration Tips
#### Testing for no arguments
If you were previously using code like:
```js
if (!program.args.length) ...
```
a partial replacement is:
```js
if (program.rawArgs.length < 3) ...
```
## [4.0.0-1] Prerelease (2019-10-08)

@@ -508,4 +530,6 @@

[#1081]: https://github.com/tj/commander.js/pull/1081
[#1091]: https://github.com/tj/commander.js/pull/1091
[Unreleased]: https://github.com/tj/commander.js/compare/master...develop
[4.0.1]: https://github.com/tj/commander.js/compare/v4.0.0..v4.0.1
[4.0.0]: https://github.com/tj/commander.js/compare/v3.0.2..v4.0.0

@@ -512,0 +536,0 @@ [4.0.0-1]: https://github.com/tj/commander.js/compare/v4.0.0-0..v4.0.0-1

24

index.js

@@ -327,2 +327,3 @@ /**

outputHelpIfNecessary(self, parsed.unknown);
self._checkForMissingMandatoryOptions();

@@ -567,2 +568,4 @@ // If there are still any unknown options, then we simply

// Note for future: we could return early if we found an action handler in parseArgs, as none of following code needed?
// <cmd> --help

@@ -572,2 +575,7 @@ if (args[0] === 'help') {

args[1] = this._helpLongFlag;
} else {
// If calling through to executable subcommand we could check for help flags before failing,
// but a somewhat unlikely case since program options not passed to executable subcommands.
// Wait for reports to see if check needed and what usage pattern is.
this._checkForMissingMandatoryOptions();
}

@@ -838,8 +846,10 @@

Command.prototype._checkForMissingMandatoryOptions = function() {
const self = this;
this.options.forEach((anOption) => {
if (anOption.mandatory && (self[anOption.attributeName()] === undefined)) {
self.missingMandatoryOptionValue(anOption);
}
});
// Walk up hierarchy so can call from action handler after checking for displaying help.
for (var cmd = this; cmd; cmd = cmd.parent) {
cmd.options.forEach((anOption) => {
if (anOption.mandatory && (cmd[anOption.attributeName()] === undefined)) {
cmd.missingMandatoryOptionValue(anOption);
}
});
}
};

@@ -923,4 +933,2 @@

this._checkForMissingMandatoryOptions();
return { args: args, unknown: unknownOptions };

@@ -927,0 +935,0 @@ };

{
"name": "commander",
"version": "4.0.0",
"version": "4.0.1",
"description": "the complete solution for node.js command-line programs",

@@ -5,0 +5,0 @@ "keywords": [

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