handle-cli-error
Advanced tools
Comparing version 2.3.0 to 2.4.0
@@ -7,3 +7,5 @@ import normalizeException from"normalize-exception"; | ||
export{validateOptions}from"./options/validate.js"; | ||
export default function handleCliError(error,opts){ | ||
@@ -10,0 +12,0 @@ const errorA=normalizeException(error); |
@@ -7,3 +7,3 @@ import normalizeException from"normalize-exception"; | ||
import{removeUndefined,applyDefaultOpts}from"./default.js"; | ||
import{validateOpts}from"./validate.js"; | ||
import{validateOptions}from"./validate.js"; | ||
@@ -15,2 +15,4 @@ | ||
}catch(error_){ | ||
error_.message=`handle-cli-error invalid usage: ${error_.message}`; | ||
const errorA=normalizeException(error_); | ||
@@ -22,3 +24,3 @@ return{error:errorA,opts:INVALID_OPTS}; | ||
const safeGetOpts=function(opts,error){ | ||
validateOpts(opts,["options"]); | ||
validateOptions(opts); | ||
const optsA=applyClassesOpts(error,opts); | ||
@@ -25,0 +27,0 @@ const optsB=applyDefaultOpts(optsA); |
@@ -7,3 +7,8 @@ import isPlainObj from"is-plain-obj"; | ||
export const validateOpts=function(opts,optName){ | ||
export const validateOptions=function(opts){ | ||
validateAllOpts(opts,[]); | ||
}; | ||
const validateAllOpts=function(opts,optName){ | ||
if(opts===undefined){ | ||
@@ -78,3 +83,3 @@ return; | ||
if(optName.length>2){ | ||
if(optName.length>1){ | ||
handleInvalidOpts("must not be defined",classes,optName); | ||
@@ -84,3 +89,3 @@ } | ||
Object.entries(classes).forEach(([className,classOpts])=>{ | ||
validateOpts(classOpts,[...optName,className]); | ||
validateAllOpts(classOpts,[...optName,className]); | ||
}); | ||
@@ -99,6 +104,4 @@ }; | ||
const fullOptName=optName.join("."); | ||
throw new Error( | ||
`handle-cli-error invalid usage: "${fullOptName}" ${message}: ${value}`); | ||
throw new Error(`"${fullOptName}" ${message}: ${value}`); | ||
}; | ||
//# sourceMappingURL=validate.js.map |
{ | ||
"name": "handle-cli-error", | ||
"version": "2.3.0", | ||
"version": "2.4.0", | ||
"type": "module", | ||
@@ -5,0 +5,0 @@ "exports": "./build/src/main.js", |
26543
260