nopt
Advanced tools
Comparing version 1.0.8 to 1.0.9
@@ -53,3 +53,5 @@ // info about each config option. | ||
, typeDefault = [false, true, null, String, Number] | ||
Object.keys(data).forEach(function (k) { | ||
if (k === "argv") return | ||
var val = data[k] | ||
@@ -82,5 +84,13 @@ , isArray = Array.isArray(val) | ||
} | ||
if (!types.hasOwnProperty(k)) { | ||
return val | ||
} | ||
// allow `--no-blah` to set 'blah' to null if null is allowed | ||
if (val === false && ~type.indexOf(null) && | ||
!(~type.indexOf(false) || ~type.indexOf(Boolean))) { | ||
val = null | ||
} | ||
var d = {} | ||
@@ -247,5 +257,2 @@ d[k] = val | ||
var isBool = no || types[arg] === Boolean || | ||
Array.isArray(types[arg]) && types[arg].indexOf(Boolean) !== -1 | ||
var isArray = types[arg] === Array || | ||
@@ -255,3 +262,11 @@ Array.isArray(types[arg]) && types[arg].indexOf(Array) !== -1 | ||
var val | ||
, la = args[i + 1] | ||
var isBool = no || | ||
types[arg] === Boolean || | ||
Array.isArray(types[arg]) && types[arg].indexOf(Boolean) !== -1 || | ||
(la === "false" && | ||
(types[arg] === null || | ||
Array.isArray(types[arg]) && ~types[arg].indexOf(null))) | ||
if (isBool) { | ||
@@ -261,3 +276,2 @@ // just set and move along | ||
// however, also support --bool true or --bool false | ||
var la = args[i + 1] | ||
if (la === "true" || la === "false") { | ||
@@ -299,3 +313,2 @@ val = JSON.parse(la) | ||
var la = args[i + 1] | ||
if (la && la.match(/^-{2,}$/)) { | ||
@@ -305,2 +318,3 @@ la = undefined | ||
} | ||
val = la === undefined ? true : la | ||
@@ -382,4 +396,4 @@ if (isArray) (data[arg] = data[arg] || []).push(val) | ||
, types = | ||
{ argv : NaN | ||
, aoa: Array | ||
{ aoa: Array | ||
, nullstream: [null, Stream] | ||
, str: String | ||
@@ -503,2 +517,8 @@ , browser : String | ||
,[]] | ||
,["--no-nullstream" | ||
,{nullstream:null} | ||
,[]] | ||
,["--nullstream false" | ||
,{nullstream:null} | ||
,[]] | ||
].forEach(function (test) { | ||
@@ -505,0 +525,0 @@ var argv = test[0].split(/\s+/) |
{ "name" : "nopt" | ||
, "version" : "1.0.8" | ||
, "version" : "1.0.9" | ||
, "description" : "Option parsing for Node, supporting types, shorthands, etc. Used by npm." | ||
@@ -4,0 +4,0 @@ , "author" : "Isaac Z. Schlueter <i@izs.me> (http://blog.izs.me/)" |
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
Non-existent author
Supply chain riskThe package was published by an npm account that no longer exists.
Found 1 instance in 1 package
25948
550
0
1