@sanity/pkg-utils
Version:
Simple utilities for modern npm packages.
38 lines (37 loc) • 841 B
JavaScript
import { statSync } from "node:fs";
import chalk from "chalk";
function fileExists(filePath) {
try {
return statSync(filePath), !0;
} catch {
return !1;
}
}
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";
}
export {
createLogger,
fileExists,
isRecord
};
//# sourceMappingURL=isRecord.js.map