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

tiny-parse-argv

Package Overview
Dependencies
Maintainers
1
Versions
16
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

tiny-parse-argv - npm Package Compare versions

Comparing version 2.1.0 to 2.1.1

7

dist/index.js

@@ -95,2 +95,3 @@ /* IMPORT */

const required = options.required || [];
const requiredSet = new Set(required);
const known = new Set([...booleans, ...strings, ...Object.keys(defaults)]);

@@ -109,4 +110,6 @@ const onMissing = options.onMissing;

if (isOverridable(parsed[key])) { // Maybe we are setting this option multiple times
const value = (strings.has(key) ? '' : positive);
setAliased(parsed, key, value, aliases);
if (!strings.has(key) || !requiredSet.has(key)) { // String options shouldn't have an inferred value if they are required
const value = (strings.has(key) ? '' : positive);
setAliased(parsed, key, value, aliases);
}
}

@@ -113,0 +116,0 @@ optionPrev = option;

@@ -5,3 +5,3 @@ {

"description": "A tiny function for parsing process.argv, a modern rewrite of a sensible subset of minimist.",
"version": "2.1.0",
"version": "2.1.1",
"type": "module",

@@ -8,0 +8,0 @@ "main": "dist/index.js",

@@ -168,2 +168,3 @@

const required = options.required || [];
const requiredSet = new Set ( required );
const known = new Set ([ ...booleans, ...strings, ...Object.keys ( defaults ) ]);

@@ -190,6 +191,10 @@ const onMissing = options.onMissing;

const value = ( strings.has ( key ) ? '' : positive );
if ( !strings.has ( key ) || !requiredSet.has ( key ) ) { // String options shouldn't have an inferred value if they are required
setAliased ( parsed, key, value, aliases );
const value = ( strings.has ( key ) ? '' : positive );
setAliased ( parsed, key, value, aliases );
}
}

@@ -196,0 +201,0 @@

@@ -86,2 +86,23 @@

it ( 'detects string flags with empty value as missing, when they are required', t => { //TODO: Maybe they should just never receive an empty value
t.plan ( 2 );
parse ( t, {
input: ['-s'],
options: {
string: ['s'],
required: ['s'],
onMissing ( flags ) {
t.deepEqual ( flags, ['s'] );
}
},
output: {
_: [],
'--': []
}
});
});
// bool: https://github.com/minimistjs/minimist/blob/main/test/bool.js

@@ -88,0 +109,0 @@

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