Socket
Socket
Sign inDemoInstall

get-options

Package Overview
Dependencies
0
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.0.0 to 1.0.1

2

index.js

@@ -353,3 +353,3 @@ #!/usr/local/bin/node --es_staging

/** Don't store solitary values in an array. Store them directly as strings */
if(currentOption.arity === 1)
if(currentOption.arity === 1 && !currentOption.variadic)
optValue = optValue[0];

@@ -356,0 +356,0 @@

{
"name": "get-options",
"version": "1.0.0",
"version": "1.0.1",
"description": "JavaScript's answer to getopts. Simple, obvious, and direct.",

@@ -5,0 +5,0 @@ "keywords": ["CLI", "getopt", "getopts", "options", "argv", "command-line", "configuration", "config"],

@@ -125,2 +125,3 @@ GetOptions

---------
* No typecasting is performed on user input. Values will *always* be stored as strings.<br/><br/>
* This is pure JavaScript, so it's not reliant on Node to work. Feel free to use it in a browser environment or whatever.<br/><br/>

@@ -127,0 +128,0 @@ * The array that's passed to the function isn't modified. If you want to overwrite the values stored in `process.argv`, do so by assignment:

@@ -97,2 +97,37 @@ "use strict";

it("Parse variadic options", function(){
let tests = [{
input: "-f one two three four five",
expected: {
options: {
files: ["one", "two", "three", "four", "five"]
},
argv: []
}
}, {
input: "-f one two three 4 5 -lA3 uno dos tres cuatro -n Ajaja",
expected: {
options: {
files: ["one", "two", "three", "4", "5"],
list: ["A", "3", "uno", "dos", "tres", "cuatro"],
name: "Ajaja"
},
argv: []
}
}];
for(let i of tests){
let result = getOpts(i.input.split(/\s+/g), {
"-f, --files": "<list...>",
"-l, --list": "<letter=[A-Za-z]> <integer=\\d+> <mystery...>",
"-n, --name": "<name>"
}, {noAliasPropagation: "first-only"});
assert.deepEqual(result, i.expected);
}
});
});
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc