Socket
Socket
Sign inDemoInstall

commander

Package Overview
Dependencies
Maintainers
5
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 2.11.0 to 2.12.0

CHANGELOG.md

35

index.js

@@ -63,2 +63,14 @@ /**

/**
* Return option name, in a camelcase format that can be used
* as a object attribute key.
*
* @return {String}
* @api private
*/
Option.prototype.attributeName = function() {
return camelcase( this.name() );
};
/**
* Check if `arg` matches the short or long flag.

@@ -159,2 +171,6 @@ *

Command.prototype.command = function(name, desc, opts) {
if(typeof desc === 'object' && desc !== null){
opts = desc;
desc = null;
}
opts = opts || {};

@@ -170,3 +186,2 @@ var args = name.split(/ +/);

}
cmd._noHelp = !!opts.noHelp;

@@ -365,3 +380,3 @@ this.commands.push(cmd);

, oname = option.name()
, name = camelcase(oname);
, name = option.attributeName();

@@ -388,3 +403,6 @@ // default as 3rd arg

// preassign only if we have a default
if (undefined !== defaultValue) self[name] = defaultValue;
if (undefined !== defaultValue) {
self[name] = defaultValue;
option.defaultValue = defaultValue;
}
}

@@ -549,3 +567,3 @@

proc = spawn('node', args, { stdio: 'inherit', customFds: [0, 1, 2] });
proc = spawn(process.argv[0], args, { stdio: 'inherit', customFds: [0, 1, 2] });
} else {

@@ -764,3 +782,3 @@ proc = spawn(bin, args, { stdio: 'inherit', customFds: [0, 1, 2] });

for (var i = 0 ; i < len; i++) {
var key = camelcase(this.options[i].name());
var key = this.options[i].attributeName();
result[key] = key === 'version' ? this._version : this[key];

@@ -887,2 +905,4 @@ }

if (alias === command._name) throw new Error('Command alias can\'t be the same as its name');
command._alias = alias;

@@ -954,4 +974,5 @@ return this;

return this.options.map(function(option) {
return pad(option.flags, width) + ' ' + option.description;
}).concat([pad('-h, --help', width) + ' ' + 'output usage information'])
return pad(option.flags, width) + ' ' + option.description
+ (option.defaultValue !== undefined ? ' (default: ' + option.defaultValue + ')' : '');
}).concat([pad('-h, --help', width) + ' ' + 'output usage information'])
.join('\n');

@@ -958,0 +979,0 @@ };

19

package.json
{
"name": "commander",
"version": "2.11.0",
"version": "2.12.0",
"description": "the complete solution for node.js command-line programs",

@@ -17,8 +17,5 @@ "keywords": [

},
"devDependencies": {
"should": "^11.2.1",
"sinon": "^2.3.5"
},
"scripts": {
"test": "make test"
"test": "make test && npm run test-typings",
"test-typings": "node_modules/typescript/bin/tsc -p tsconfig.json"
},

@@ -29,3 +26,11 @@ "main": "index",

],
"dependencies": {}
"dependencies": {
"@types/node": "^7.0.48"
},
"devDependencies": {
"should": "^11.2.1",
"sinon": "^2.3.5",
"typescript": "^2.6.1"
},
"typings": "typings/index.d.ts"
}

@@ -47,3 +47,22 @@ # Commander.js

Note that multi-word options starting with `--no` prefix negate the boolean value of the following word. For example, `--no-sauce` sets the value of `program.sauce` to false.
```js
#!/usr/bin/env node
/**
* Module dependencies.
*/
var program = require('commander');
program
.option('--no-sauce', 'Remove sauce')
.parse(process.argv);
console.log('you ordered a pizza');
if (program.sauce) console.log(' with sauce');
else console.log(' without sauce');
```
## Coercion

@@ -289,5 +308,5 @@

if (!process.argv.slice(2).length) {
program.outputHelp(make_red);
}
if (!process.argv.slice(2).length) {
program.outputHelp(make_red);
}

@@ -294,0 +313,0 @@ function make_red(txt) {

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