Comparing version 3.5.4 to 3.6.0
@@ -129,2 +129,6 @@ var assert = require('assert'), | ||
else { | ||
if (typeof value === 'function') { | ||
defaultDescription = usage.functionDescription(value, defaultDescription); | ||
value = value.call(); | ||
} | ||
options.defaultDescription[key] = defaultDescription; | ||
@@ -131,0 +135,0 @@ options.default[key] = value; |
@@ -7,2 +7,6 @@ // fancy-pants parsing of argv, originally forked | ||
function increment (orig) { | ||
return orig !== undefined ? orig + 1 : 0; | ||
} | ||
module.exports = function (args, opts) { | ||
@@ -229,3 +233,3 @@ if (!opts) opts = {}; | ||
if (checkAllAliases(key, flags.counts)) { | ||
value = function(orig) { return orig !== undefined ? orig + 1 : 0; }; | ||
value = increment; | ||
} | ||
@@ -281,3 +285,3 @@ | ||
try { | ||
var config = JSON.parse(fs.readFileSync(configPath, 'utf8')); | ||
var config = require(path.resolve(process.cwd(), configPath)); | ||
Object.keys(config).forEach(function (key) { | ||
@@ -328,4 +332,4 @@ // setting arguments via CLI takes precedence over | ||
var key = keys[keys.length - 1]; | ||
if (typeof value === 'function') { | ||
o[key] = value(o[key]); | ||
if (value === increment) { | ||
o[key] = increment(o[key]); | ||
} | ||
@@ -332,0 +336,0 @@ else if (o[key] === undefined && checkAllAliases(key, flags.arrays)) { |
@@ -214,2 +214,10 @@ // this file handles outputting usage instructions, | ||
self.functionDescription = function (fn, defaultDescription) { | ||
if (defaultDescription) { | ||
return defaultDescription; | ||
} | ||
var description = fn.name ? decamelize(fn.name, '-') : 'generated-value'; | ||
return ['(', description, ')'].join(''); | ||
} | ||
// format the default-value-string displayed in | ||
@@ -229,5 +237,2 @@ // the right-hand column. | ||
break; | ||
case 'function': | ||
string += '(' + (value.name.length ? decamelize(value.name, '-') : 'generated-value') + ')' | ||
break; | ||
default: | ||
@@ -234,0 +239,0 @@ string += value; |
{ | ||
"name": "yargs", | ||
"version": "3.5.4", | ||
"version": "3.6.0", | ||
"description": "Light-weight option parsing with an argv hash. No optstrings attached.", | ||
@@ -5,0 +5,0 @@ "main": "./index.js", |
@@ -690,6 +690,6 @@ yargs | ||
.showHelp(fn=console.error) | ||
.showHelp(consoleLevel='error') | ||
--------------------------- | ||
Print the usage data using `fn` for printing. | ||
Print the usage data using the [`console`](https://nodejs.org/api/console.html) function `consoleLevel` for printing. | ||
@@ -704,2 +704,8 @@ Example: | ||
Or, to print the usage data to `stdout` instead, you can specify the use of `console.log`: | ||
``` | ||
yargs.showHelp("log"); | ||
``` | ||
Later on, ```argv``` can be retrived with ```yargs.argv``` | ||
@@ -706,0 +712,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
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
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
104937
10
1304
908
6