UNPKG

handle-cli-error

Version:

💣 Error handler for CLI applications 💥

27 lines (17 loc) • 479 B
import{excludeKeys}from"filter-obj"; import{DEFAULT_EXIT_CODE}from"../exit.js"; import{DEFAULT_TIMEOUT}from"../timeout.js"; export const applyDefaultOpts=(opts)=>({ ...DEFAULT_OPTS, ...removeUndefined(opts) }); export const DEFAULT_OPTS={ silent:false, exitCode:DEFAULT_EXIT_CODE, timeout:DEFAULT_TIMEOUT, log(message){ console.error(message) } }; export const removeUndefined=(object)=>excludeKeys(object,isUndefined); const isUndefined=(key,value)=>value===undefined;