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

argly

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

argly - npm Package Compare versions

Comparing version 1.1.1 to 1.2.0

2

package.json

@@ -39,3 +39,3 @@ {

},
"version": "1.1.1"
"version": "1.2.0"
}

@@ -83,3 +83,3 @@ var optionRegExp = /^--?(.+)$/;

function handleDefaults(state, onError) {
function handleDefaults(parser, state, onError) {
state.options.getOptions().forEach(function(option) {

@@ -95,2 +95,6 @@ var targetProperty = option.targetProperty;

if (typeof defaultValue === 'function') {
defaultValue = defaultValue.call(parser);
}
var handler;

@@ -488,3 +492,3 @@ // If the option has a type and it is not a complex type, we validate

finishLastOption();
handleDefaults(state, onError);
handleDefaults(this, state, onError);

@@ -491,0 +495,0 @@ // Run the validators

@@ -228,2 +228,49 @@ 'use strict';

it('should allow default values as functions', function() {
var parser = require('../')
.createParser({
'--foo -f': {
type: 'string',
defaultValue: function() {
return 'bar';
}
},
'--bar -b': {
type: 'string'
}
});
var parsed = parser.parse('--bar test'.split(/\s/));
expect(parsed).to.deep.equal({
foo: 'bar',
bar: 'test'
});
});
it('should call defaultValue function with Parser context', function() {
var usage = 'Usage: test';
var parser = require('../')
.createParser({
'--foo -f': {
type: 'string',
defaultValue: function() {
expect(this.getUsageString().indexOf(usage)).to.not.equal(-1);
return 'bar';
}
},
'--bar -b': {
type: 'string'
}
})
.usage(usage);
var parsed = parser.parse('--bar test'.split(/\s/));
expect(parsed).to.deep.equal({
foo: 'bar',
bar: 'test'
});
});
it('should allow default values use pseudo defaults', function() {

@@ -230,0 +277,0 @@ var parser = require('../')

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