Comparing version 1.2.0 to 1.2.1
# node-dashdash changelog | ||
## 1.2.1 | ||
- Fix for `parse.help({includeEnv: true, ...})` handling to ensure that an | ||
option with an `env` **but no `help`** still has the "Environment: ..." | ||
output. E.g.: | ||
{ names: ['foo'], type: 'string', env: 'FOO' } | ||
... | ||
--foo=ARG Environment: FOO=ARG | ||
## 1.2.0 | ||
@@ -4,0 +17,0 @@ |
@@ -519,3 +519,3 @@ /** | ||
this.options.forEach(function (o, i) { | ||
if (!o.help) { | ||
if (!o.help && !(config.includeEnv && o.env)) { | ||
return; | ||
@@ -530,3 +530,3 @@ } | ||
} | ||
var help = o.help; | ||
var help = (o.help || '').trim(); | ||
if (o.env && o.env.length && config.includeEnv) { | ||
@@ -536,3 +536,6 @@ if (help.length && !~'.!?'.indexOf(help.slice(-1))) { | ||
} | ||
help += ' Environment: '; | ||
if (help.length) { | ||
help += ' '; | ||
} | ||
help += 'Environment: '; | ||
var type = types[o.type]; | ||
@@ -539,0 +542,0 @@ var arg = o.helpArg || type.helpArg || 'ARG'; |
{ | ||
"name": "dashdash", | ||
"description": "A light, featureful and explicit option parsing library.", | ||
"version": "1.2.0", | ||
"version": "1.2.1", | ||
"author": "Trent Mick (trentm.com)", | ||
@@ -6,0 +6,0 @@ "repository": { |
@@ -531,2 +531,28 @@ /* | ||
// env help | ||
{ | ||
options: [ | ||
{names: ['a'], type: 'string', env: 'A', help: 'Phrase'}, | ||
{names: ['b'], type: 'string', env: 'B', help: 'Sentence.'}, | ||
{names: ['c'], type: 'string', env: 'C', help: 'Question?'}, | ||
{names: ['d'], type: 'string', env: 'D', help: 'Exclamation!'}, | ||
{names: ['e'], type: 'string', env: 'E', help: ' '}, | ||
{names: ['f'], type: 'string', env: 'F', help: ''}, | ||
{names: ['g'], type: 'string', env: 'G'}, | ||
{names: ['h'], type: 'bool', env: 'H'}, | ||
], | ||
argv: 'node tool.js --help', | ||
helpOptions: { includeEnv: true }, | ||
expectHelp: [ | ||
/-a ARG\s+Phrase. Environment: A=ARG/, | ||
/-b ARG\s+Sentence. Environment: B=ARG/, | ||
/-c ARG\s+Question\? Environment: C=ARG/, | ||
/-d ARG\s+Exclamation! Environment: D=ARG/, | ||
/-e ARG\s+Environment: E=ARG/, | ||
/-f ARG\s+Environment: F=ARG/, | ||
/-g ARG\s+Environment: G=ARG/, | ||
/-h\s+Environment: H=1/, | ||
] | ||
}, | ||
// env (number) | ||
@@ -611,7 +637,14 @@ { | ||
delete c.expect; | ||
var expectHelp = c.expectHelp; | ||
if (typeof (expectHelp) === 'string') { | ||
expectHelp = new RegExp(expectHelp); | ||
var expectHelps = c.expectHelp; | ||
if (!Array.isArray(expectHelps)) { | ||
expectHelps = expectHelps ? [expectHelps] : []; | ||
for (var i = 0; i < expectHelps.length; i++) { | ||
if (typeof (expectHelps[i]) === 'string') { | ||
expectHelps[i] = new RegExp(expectHelps[i]); | ||
} | ||
} | ||
} | ||
delete c.expectHelp; | ||
var helpOptions = c.helpOptions; | ||
delete c.helpOptions; | ||
var argv = c.argv; | ||
@@ -658,6 +691,8 @@ delete c.argv; | ||
} | ||
if (expectHelp) { | ||
var help = parser.help(); | ||
t.ok(expectHelp.test(help), format( | ||
'help did not match %s: "%s"', expectHelp, help)); | ||
if (expectHelps.length) { | ||
var help = parser.help(helpOptions); | ||
expectHelps.forEach(function (eH) { | ||
t.ok(eH.test(help), format( | ||
'help did not match %s: "%s"', eH, help)); | ||
}); | ||
} | ||
@@ -664,0 +699,0 @@ t.end(); |
Sorry, the diff of this file is not supported yet
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
Copyleft License
License(Experimental) Copyleft license information was found.
Found 1 instance in 1 package
Mixed license
License(Experimental) Package contains multiple licenses.
Found 1 instance in 1 package
Non-permissive License
License(Experimental) A license not known to be considered permissive was found.
Found 1 instance in 1 package
Unidentified License
License(Experimental) Something that seems like a license was found, but its contents could not be matched with a known license.
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
102126
1300
4
70