Socket
Socket
Sign inDemoInstall

dashdash

Package Overview
Dependencies
Maintainers
1
Versions
29
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

dashdash - npm Package Compare versions

Comparing version 1.2.0 to 1.2.1

13

CHANGES.md
# 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 @@

9

lib/dashdash.js

@@ -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

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