Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

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.3.0 to 1.3.1

14

CHANGES.md
# node-dashdash changelog
## 1.3.1
- [issue #1] Fix an envvar not winning over an option 'default'. Previously
an option with both `default` and `env` would never take a value from the
environment variable. E.g. `FOO_FILE` would never work here:
options: [ {
names: ['file', 'f'],
env: 'FOO_FILE',
'default': 'default.file',
type: 'string'
} ],
## 1.3.0

@@ -4,0 +18,0 @@

15

lib/dashdash.js

@@ -291,11 +291,4 @@ /**

var env = inputs.env || process.env;
// Setup default values
var opts = {};
var _order = [];
this.options.forEach(function (o) {
if (o.default) {
opts[o.key] = o.default;
}
});

@@ -425,2 +418,10 @@ function addOpt(option, optstr, key, val, from) {

// Apply default values.
this.options.forEach(function (o) {
if (o.default && opts[o.key] === undefined) {
opts[o.key] = o.default;
}
});
opts._order = _order;

@@ -427,0 +428,0 @@ opts._args = _args;

{
"name": "dashdash",
"description": "A light, featureful and explicit option parsing library.",
"version": "1.3.0",
"version": "1.3.1",
"author": "Trent Mick (trentm.com)",

@@ -6,0 +6,0 @@ "repository": {

@@ -630,2 +630,36 @@ /*

},
// issue #1: 'env' not taking precendence over 'default'
{
options: [ {
names: ['file', 'f'],
env: 'FOO_FILE',
'default': 'default.file',
type: 'string'
} ],
argv: 'node foo.js',
expect: { file: 'default.file', _args: [] }
},
{
options: [ {
names: ['file', 'f'],
env: 'FOO_FILE',
'default': 'default.file',
type: 'string'
} ],
env: {FOO_FILE: 'env.file'},
argv: 'node foo.js',
expect: { file: 'env.file', _args: [] }
},
{
options: [ {
names: ['file', 'f'],
env: 'FOO_FILE',
'default': 'default.file',
type: 'string'
} ],
argv: 'node foo.js -f argv.file',
env: {FOO_FILE: 'env.file'},
expect: { file: 'argv.file', _args: [] }
},
];

@@ -632,0 +666,0 @@ cases.forEach(function (c, i) {

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