Socket
Socket
Sign inDemoInstall

commander

Package Overview
Dependencies
Maintainers
1
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 0.1.0 to 0.2.0

test/test.options.camelcase.js

5

History.md
0.2.0 / 2011-09-26
==================
* Allow for defaults that are not just boolean. Default peassignment only occurs for --no-*, optional, and required arguments. [Jim Isaacs]
0.1.0 / 2011-08-24

@@ -3,0 +8,0 @@ ==================

34

lib/commander.js

@@ -264,3 +264,4 @@ /*!

, option = new Option(flags, description)
, name = camelcase(option.name());
, oname = option.name()
, name = camelcase(oname);

@@ -270,8 +271,10 @@ // default as 3rd arg

// when --no-* we default to true
if (false == option.bool) defaultValue = true;
// preassign default value only for --no-*, [optional], or <required>
if (false == option.bool || option.optional || option.required) {
// when --no-* we make sure default is true
if (false == option.bool) defaultValue = true;
// preassign only if we have a default
if (undefined !== defaultValue) self[name] = defaultValue;
}
// default
if (undefined !== defaultValue) self[name] = defaultValue;
// register the option

@@ -282,10 +285,17 @@ this.options.push(option);

// and conditionally invoke the callback
this.on(name, function(val){
this.on(oname, function(val){
// coercion
if (null != val && fn) val = fn(val);
// assign value
self[name] = null == val
? option.bool
: val;
// unassigned or bool
if (/undefined|boolean/.test(typeof self[name])) {
// if no value, bool true, and we have a default, then use it!
self[name] = null == val
? (option.bool
? defaultValue || true : false
) : val;
} else {
// reassign
self[name] = val;
}
});

@@ -896,2 +906,2 @@

process.exit(0);
});
});
{
"name": "commander"
, "version": "0.1.0"
, "version": "0.2.0"
, "description": "the complete solution for node.js command-line programs"
, "keywords": ["command", "option", "parser", "prompt", "stdin"]
, "author": "TJ Holowaychuk <tj@vision-media.ca>"
, "repository": { "type": "git", "url": "https://github.com/visionmedia/commander.js.git" }
, "dependencies": {}

@@ -8,0 +9,0 @@ , "devDependencies": { "should": ">= 0.0.1" }

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