summaryrefslogtreecommitdiff
path: root/node_modules/kleur/colors.mjs
diff options
context:
space:
mode:
authorShipwreckt <me@shipwreckt.co.uk>2025-10-31 20:02:14 +0000
committerShipwreckt <me@shipwreckt.co.uk>2025-10-31 20:02:14 +0000
commit7a52ddeba2a68388b544f529d2d92104420f77b0 (patch)
tree15ddd47457a2cb4a96060747437d36474e4f6b4e /node_modules/kleur/colors.mjs
parent53d6ae2b5568437afa5e4995580a3fb679b7b91b (diff)
Changed from static to 11ty!
Diffstat (limited to 'node_modules/kleur/colors.mjs')
-rw-r--r--node_modules/kleur/colors.mjs53
1 files changed, 53 insertions, 0 deletions
diff --git a/node_modules/kleur/colors.mjs b/node_modules/kleur/colors.mjs
new file mode 100644
index 0000000..e9feb83
--- /dev/null
+++ b/node_modules/kleur/colors.mjs
@@ -0,0 +1,53 @@
+let FORCE_COLOR, NODE_DISABLE_COLORS, NO_COLOR, TERM, isTTY=true;
+if (typeof process !== 'undefined') {
+ ({ FORCE_COLOR, NODE_DISABLE_COLORS, NO_COLOR, TERM } = process.env || {});
+ isTTY = process.stdout && process.stdout.isTTY;
+}
+
+export const $ = {
+ enabled: !NODE_DISABLE_COLORS && NO_COLOR == null && TERM !== 'dumb' && (
+ FORCE_COLOR != null && FORCE_COLOR !== '0' || isTTY
+ )
+}
+
+function init(x, y) {
+ let rgx = new RegExp(`\\x1b\\[${y}m`, 'g');
+ let open = `\x1b[${x}m`, close = `\x1b[${y}m`;
+
+ return function (txt) {
+ if (!$.enabled || txt == null) return txt;
+ return open + (!!~(''+txt).indexOf(close) ? txt.replace(rgx, close + open) : txt) + close;
+ };
+}
+
+// modifiers
+export const reset = init(0, 0);
+export const bold = init(1, 22);
+export const dim = init(2, 22);
+export const italic = init(3, 23);
+export const underline = init(4, 24);
+export const inverse = init(7, 27);
+export const hidden = init(8, 28);
+export const strikethrough = init(9, 29);
+
+// colors
+export const black = init(30, 39);
+export const red = init(31, 39);
+export const green = init(32, 39);
+export const yellow = init(33, 39);
+export const blue = init(34, 39);
+export const magenta = init(35, 39);
+export const cyan = init(36, 39);
+export const white = init(37, 39);
+export const gray = init(90, 39);
+export const grey = init(90, 39);
+
+// background colors
+export const bgBlack = init(40, 49);
+export const bgRed = init(41, 49);
+export const bgGreen = init(42, 49);
+export const bgYellow = init(43, 49);
+export const bgBlue = init(44, 49);
+export const bgMagenta = init(45, 49);
+export const bgCyan = init(46, 49);
+export const bgWhite = init(47, 49);