@mikro-orm/core
Version:
TypeScript ORM for Node.js based on Data Mapper, Unit of Work and Identity Map patterns. Supports MongoDB, MySQL, PostgreSQL and SQLite databases as well as usage with vanilla JavaScript.
15 lines (14 loc) • 720 B
JavaScript
import { getEnv } from '../utils/env-vars.js';
const bool = (k) => ['true', 't', '1'].includes(getEnv(k)?.toLowerCase() ?? '');
const boolIfDefined = (k) => (getEnv(k) != null ? bool(k) : true);
const enabled = () => !bool('NO_COLOR') && !bool('MIKRO_ORM_NO_COLOR') && boolIfDefined('FORCE_COLOR') && boolIfDefined('MIKRO_ORM_COLORS');
const wrap = (fn) => (text) => enabled() ? fn(text) : text;
/** @internal */
export const colors = {
red: wrap((text) => `\x1B[31m${text}\x1B[39m`),
green: wrap((text) => `\x1B[32m${text}\x1B[39m`),
yellow: wrap((text) => `\x1B[33m${text}\x1B[39m`),
grey: wrap((text) => `\x1B[90m${text}\x1B[39m`),
cyan: wrap((text) => `\x1B[36m${text}\x1B[39m`),
enabled,
};