UNPKG

nstdlib-nightly

Version:

Node.js standard library converted to runtime-agnostic ES modules.

53 lines (48 loc) 1.71 kB
// Source: https://github.com/nodejs/node/blob/65eff1eb/lib/internal/util/colors.js import * as __hoisted_internal_tty__ from "nstdlib/lib/internal/tty"; let internalTTy; function lazyInternalTTY() { internalTTy ??= __hoisted_internal_tty__; return internalTTy; } const _export_blue_ = ""; export { _export_blue_ as blue }; const _export_green_ = ""; export { _export_green_ as green }; const _export_white_ = ""; export { _export_white_ as white }; const _export_red_ = ""; export { _export_red_ as red }; const _export_gray_ = ""; export { _export_gray_ as gray }; const _export_clear_ = ""; export { _export_clear_ as clear }; const _export_hasColors_ = false; export { _export_hasColors_ as hasColors }; const _export_shouldColorize_ = function (stream) { if (process.env.FORCE_COLOR !== undefined) { return lazyInternalTTY().getColorDepth() > 2; } return ( stream?.isTTY && (typeof stream.getColorDepth === "function" ? stream.getColorDepth() > 2 : true) ); }; export { _export_shouldColorize_ as shouldColorize }; const _export_refresh_ = function () { if (process.stderr.isTTY) { const hasColors = module.exports.shouldColorize(process.stderr); module.exports.blue = hasColors ? "\u001b[34m" : ""; module.exports.green = hasColors ? "\u001b[32m" : ""; module.exports.white = hasColors ? "\u001b[39m" : ""; module.exports.yellow = hasColors ? "\u001b[33m" : ""; module.exports.red = hasColors ? "\u001b[31m" : ""; module.exports.gray = hasColors ? "\u001b[90m" : ""; module.exports.clear = hasColors ? "\u001bc" : ""; module.exports.hasColors = hasColors; } }; export { _export_refresh_ as refresh }; module.exports.refresh();