aboutsummaryrefslogtreecommitdiff
path: root/node_modules/picocolors/picocolors.js
diff options
context:
space:
mode:
authorJoel Kronqvist <work.joelkronqvist@pm.me>2022-03-11 20:46:06 +0200
committerJoel Kronqvist <work.joelkronqvist@pm.me>2022-03-11 20:46:06 +0200
commit080c5819d87b933816d724a83f3bf4f1686770a7 (patch)
tree4a2ccc68b27edf7d4cbc586c932cc7542b655e19 /node_modules/picocolors/picocolors.js
parent5ac7049a9d30733165cc212dee308163c2a14644 (diff)
parentd003b82235a9329f912522a2f70aa950dfce4998 (diff)
downloadLYLLRuoka-080c5819d87b933816d724a83f3bf4f1686770a7.tar.gz
LYLLRuoka-080c5819d87b933816d724a83f3bf4f1686770a7.zip
Merge branch 'master' of https://github.com/JoelHMikael/FoodJS
Updating remote changes
Diffstat (limited to 'node_modules/picocolors/picocolors.js')
-rw-r--r--node_modules/picocolors/picocolors.js58
1 files changed, 58 insertions, 0 deletions
diff --git a/node_modules/picocolors/picocolors.js b/node_modules/picocolors/picocolors.js
new file mode 100644
index 0000000..fdb6304
--- /dev/null
+++ b/node_modules/picocolors/picocolors.js
@@ -0,0 +1,58 @@
+let tty = require("tty")
+
+let isColorSupported =
+ !("NO_COLOR" in process.env || process.argv.includes("--no-color")) &&
+ ("FORCE_COLOR" in process.env ||
+ process.argv.includes("--color") ||
+ process.platform === "win32" ||
+ (tty.isatty(1) && process.env.TERM !== "dumb") ||
+ "CI" in process.env)
+
+let formatter =
+ (open, close, replace = open) =>
+ input => {
+ let string = "" + input
+ let index = string.indexOf(close, open.length)
+ return ~index
+ ? open + replaceClose(string, close, replace, index) + close
+ : open + string + close
+ }
+
+let replaceClose = (string, close, replace, index) => {
+ let start = string.substring(0, index) + replace
+ let end = string.substring(index + close.length)
+ let nextIndex = end.indexOf(close)
+ return ~nextIndex ? start + replaceClose(end, close, replace, nextIndex) : start + end
+}
+
+let createColors = (enabled = isColorSupported) => ({
+ isColorSupported: enabled,
+ reset: enabled ? s => `\x1b[0m${s}\x1b[0m` : String,
+ bold: enabled ? formatter("\x1b[1m", "\x1b[22m", "\x1b[22m\x1b[1m") : String,
+ dim: enabled ? formatter("\x1b[2m", "\x1b[22m", "\x1b[22m\x1b[2m") : String,
+ italic: enabled ? formatter("\x1b[3m", "\x1b[23m") : String,
+ underline: enabled ? formatter("\x1b[4m", "\x1b[24m") : String,
+ inverse: enabled ? formatter("\x1b[7m", "\x1b[27m") : String,
+ hidden: enabled ? formatter("\x1b[8m", "\x1b[28m") : String,
+ strikethrough: enabled ? formatter("\x1b[9m", "\x1b[29m") : String,
+ black: enabled ? formatter("\x1b[30m", "\x1b[39m") : String,
+ red: enabled ? formatter("\x1b[31m", "\x1b[39m") : String,
+ green: enabled ? formatter("\x1b[32m", "\x1b[39m") : String,
+ yellow: enabled ? formatter("\x1b[33m", "\x1b[39m") : String,
+ blue: enabled ? formatter("\x1b[34m", "\x1b[39m") : String,
+ magenta: enabled ? formatter("\x1b[35m", "\x1b[39m") : String,
+ cyan: enabled ? formatter("\x1b[36m", "\x1b[39m") : String,
+ white: enabled ? formatter("\x1b[37m", "\x1b[39m") : String,
+ gray: enabled ? formatter("\x1b[90m", "\x1b[39m") : String,
+ bgBlack: enabled ? formatter("\x1b[40m", "\x1b[49m") : String,
+ bgRed: enabled ? formatter("\x1b[41m", "\x1b[49m") : String,
+ bgGreen: enabled ? formatter("\x1b[42m", "\x1b[49m") : String,
+ bgYellow: enabled ? formatter("\x1b[43m", "\x1b[49m") : String,
+ bgBlue: enabled ? formatter("\x1b[44m", "\x1b[49m") : String,
+ bgMagenta: enabled ? formatter("\x1b[45m", "\x1b[49m") : String,
+ bgCyan: enabled ? formatter("\x1b[46m", "\x1b[49m") : String,
+ bgWhite: enabled ? formatter("\x1b[47m", "\x1b[49m") : String,
+})
+
+module.exports = createColors()
+module.exports.createColors = createColors