Comparing version 3.18.0 to 3.18.1
## Change Log | ||
### v3.18.1 (2015/08/12 05:53 +00:00) | ||
- [#228](https://github.com/bcoe/yargs/pull/228) notes about embedding yargs in Electron (@etiktin) | ||
- [#223](https://github.com/bcoe/yargs/pull/223) make booleans work in config files (@sgentle) | ||
### v3.18.0 (2015/08/06 20:05 +00:00) | ||
@@ -4,0 +9,0 @@ - [#222](https://github.com/bcoe/yargs/pull/222) updates fr locale (@nexdrew) |
@@ -279,2 +279,4 @@ var assert = require('assert') | ||
self.demand(key, demand) | ||
} if ('config' in opt) { | ||
self.config(key) | ||
} if ('default' in opt) { | ||
@@ -281,0 +283,0 @@ self.default(key, opt.default) |
@@ -15,3 +15,3 @@ // fancy-pants parsing of argv, originally forked | ||
var error = null | ||
var flags = { arrays: {}, bools: {}, strings: {}, counts: {}, normalize: {}, configs: {} } | ||
var flags = { arrays: {}, bools: {}, strings: {}, counts: {}, normalize: {}, configs: {}, defaulted: {} } | ||
@@ -62,2 +62,3 @@ ;[].concat(opts['array']).filter(Boolean).forEach(function (key) { | ||
setArg(key, !(key in defaults) ? false : defaults[key]) | ||
setDefaulted(key) | ||
}) | ||
@@ -263,2 +264,4 @@ | ||
function setArg (key, val) { | ||
unsetDefaulted(key) | ||
// handle parsing boolean arguments --foo=true --bar false. | ||
@@ -334,3 +337,3 @@ if (checkAllAliases(key, flags.bools) || checkAllAliases(key, flags.counts)) { | ||
// values within the config file. | ||
if (argv[key] === undefined) { | ||
if (argv[key] === undefined || (flags.defaulted[key])) { | ||
delete argv[key] | ||
@@ -422,2 +425,14 @@ setArg(key, config[key]) | ||
function setDefaulted (key) { | ||
[].concat(aliases[key] || [], key).forEach(function (k) { | ||
flags.defaulted[k] = true | ||
}) | ||
} | ||
function unsetDefaulted (key) { | ||
[].concat(aliases[key] || [], key).forEach(function (k) { | ||
delete flags.defaulted[k] | ||
}) | ||
} | ||
// return a default value, given the type of a flag., | ||
@@ -424,0 +439,0 @@ // e.g., key of type 'string' will default to '', rather than 'true'. |
{ | ||
"name": "yargs", | ||
"version": "3.18.0", | ||
"version": "3.18.1", | ||
"description": "Light-weight option parsing with an argv hash. No optstrings attached.", | ||
@@ -26,3 +26,3 @@ "main": "./index.js", | ||
"nyc": "^3.1.0", | ||
"standard": "^4.4.0" | ||
"standard": "^5.0.2" | ||
}, | ||
@@ -29,0 +29,0 @@ "scripts": { |
@@ -389,2 +389,7 @@ yargs | ||
If `yargs` is executed in an environment that embeds node and there's no script name (e.g. [Electron] | ||
(http://electron.atom.io/) or [nw.js](http://nwjs.io/)), it will ignore the first parameter since it | ||
expects it to be the script name. In order to override this behavior, use `.parse(process.argv.slice(1))` | ||
instead of `.argv` and the first parameter won't be ignored. | ||
.array(key) | ||
@@ -391,0 +396,0 @@ ---------- |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
119174
1551
1071
0