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.5.0 to 2.5.1

2

dist/index.js

@@ -74,3 +74,3 @@ /* IMPORT */

const parseCharSeparator = (argv) => {
const re = /^-([a-zA-Z0-9]{2,})([^]*)$/;
const re = /^-([a-zA-Z0-9\.]{2,})([^]*)$/;
return parseWithRegExp(argv, re, (_, chars) => chars.split('').map(char => `-${char}`));

@@ -77,0 +77,0 @@ };

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

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

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

@@ -24,2 +24,4 @@ # Tiny Parse Argv

- `options.default`: an object containing default values, which will be used if not overridded by the `argv` array.
- `options.incompatible`: an object mapping flags with other flags they are incompatible with.
- `options.onIncompatible`: a function that will be called if any pairs of flags that are incompatible with each other is detected.
- `options.onInvalid`: a function that will be called if any of the provided flags have an invalid value, e.g. a boolean value for a string flag.

@@ -26,0 +28,0 @@ - `options.onMissing`: a function that will be called if any of the required flags is missing. If a default value is provided for a flag it won't be considered as missing.

@@ -135,3 +135,3 @@

const re = /^-([a-zA-Z0-9]{2,})([^]*)$/;
const re = /^-([a-zA-Z0-9\.]{2,})([^]*)$/;

@@ -138,0 +138,0 @@ return parseWithRegExp ( argv, re, ( _, chars ) => chars.split ( '' ).map ( char => `-${char}` ) );

@@ -170,2 +170,18 @@

it ( 'supports dotted shorthand flag, with implicit splits', t => {
parse ( t, {
input: ['-.abc'],
output: {
'.': true,
a: true,
b: true,
c: true,
_: [],
'--': []
}
});
});
it ( 'supports dotted longhand flags', t => {

@@ -275,2 +291,38 @@

it ( 'detects the following in this order: unknown, missing, invalid, incompatible', t => {
const order = [];
const expected = ['unknown', 'missing', 'invalid', 'incompatible'];
parse ( t, {
input: ['--unknown', '--bool', '--incompatible'],
options: {
string: ['bool'],
required: ['missing'],
incompatible: { 'bool': ['incompatible'] },
onIncompatible () {
order.push ( 'incompatible' );
},
onMissing () {
order.push ( 'missing' );
},
onInvalid () {
order.push ( 'invalid' );
},
onUnknown () {
order.push ( 'unknown' );
}
},
output: {
unknown: true,
incompatible: true,
_: [],
'--': []
}
});
t.deepEqual ( order, expected );
});
// bool: https://github.com/minimistjs/minimist/blob/main/test/bool.js

@@ -277,0 +329,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