UNPKG

@sanity/pkg-utils

Version:

Simple utilities for modern npm packages.

33 lines (32 loc) 840 B
import chalk from "chalk"; function createLogger(quiet = !1) { return { log: (...args) => { quiet || console.log(...args); }, info: (...args) => { quiet || console.log(chalk.blue("[info]"), ...args); }, warn: (...args) => { console.log(chalk.yellow("[warning]"), ...args); }, error: (...args) => { console.log(chalk.red("[error]"), ...args); }, success: (...args) => { quiet || console.log(chalk.green("[success]"), ...args); } }; } function isRecord(value) { return !!value && !Array.isArray(value) && typeof value == "object"; } function handleError(err) { err instanceof Error ? console.error(chalk.red("error"), err.stack) : console.error(err), process.exit(1); } export { createLogger, handleError, isRecord }; //# sourceMappingURL=handleError.js.map