gulp-execa
Version:
Gulp.js command execution for humans
26 lines (20 loc) • 496 B
JavaScript
import{throwError}from"../error.js";
export const validateCustom=({opts})=>{
Object.entries(ENUM_OPTS).forEach(([attrName,allowed])=>{
validateEnum({attrName,allowed,opts})
})
};
const ENUM_OPTS={
result:new Set(["save","replace"]),
from:new Set(["stdout","stderr","all"])
};
const validateEnum=({attrName,allowed,opts:{[attrName]:value}})=>{
if(value===undefined||allowed.has(value)){
return
}
throwError(
`Option '${attrName}' '${value}' must be one of: ${[...allowed].join(
", "
)}`
)
};