summaryrefslogtreecommitdiff
path: root/node_modules/picocolors
diff options
context:
space:
mode:
authorlittleblack111 <littleblack11111@gmail.com>2024-05-14 14:05:49 +0800
committerlittleblack111 <littleblack11111@gmail.com>2024-05-14 14:05:49 +0800
commit06823fbf1c2e763a5bf76c3990ca98fbbcd98691 (patch)
tree4280bece3888d12a022093bf1a9cd1b049393602 /node_modules/picocolors
parent1368909b3cd552dbb0d12d5863c597f5be46177d (diff)
updated node_modules
Diffstat (limited to 'node_modules/picocolors')
-rw-r--r--node_modules/picocolors/package.json2
-rw-r--r--node_modules/picocolors/picocolors.js85
2 files changed, 47 insertions, 40 deletions
diff --git a/node_modules/picocolors/package.json b/node_modules/picocolors/package.json
index 85a12d52..8cdcf5f3 100644
--- a/node_modules/picocolors/package.json
+++ b/node_modules/picocolors/package.json
@@ -1,6 +1,6 @@
{
"name": "picocolors",
- "version": "1.0.0",
+ "version": "1.0.1",
"main": "./picocolors.js",
"types": "./picocolors.d.ts",
"browser": {
diff --git a/node_modules/picocolors/picocolors.js b/node_modules/picocolors/picocolors.js
index fdb63045..8b8a23e4 100644
--- a/node_modules/picocolors/picocolors.js
+++ b/node_modules/picocolors/picocolors.js
@@ -1,12 +1,12 @@
-let tty = require("tty")
-
+let argv = process.argv || [],
+ env = process.env
let isColorSupported =
- !("NO_COLOR" in process.env || process.argv.includes("--no-color")) &&
- ("FORCE_COLOR" in process.env ||
- process.argv.includes("--color") ||
+ !("NO_COLOR" in env || argv.includes("--no-color")) &&
+ ("FORCE_COLOR" in env ||
+ argv.includes("--color") ||
process.platform === "win32" ||
- (tty.isatty(1) && process.env.TERM !== "dumb") ||
- "CI" in process.env)
+ (require != null && require("tty").isatty(1) && env.TERM !== "dumb") ||
+ "CI" in env)
let formatter =
(open, close, replace = open) =>
@@ -19,40 +19,47 @@ let formatter =
}
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 result = ""
+ let cursor = 0
+ do {
+ result += string.substring(cursor, index) + replace
+ cursor = index + close.length
+ index = string.indexOf(close, cursor)
+ } while (~index)
+ return result + string.substring(cursor)
}
-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,
-})
+let createColors = (enabled = isColorSupported) => {
+ let init = enabled ? formatter : () => String
+ return {
+ isColorSupported: enabled,
+ reset: init("\x1b[0m", "\x1b[0m"),
+ bold: init("\x1b[1m", "\x1b[22m", "\x1b[22m\x1b[1m"),
+ dim: init("\x1b[2m", "\x1b[22m", "\x1b[22m\x1b[2m"),
+ italic: init("\x1b[3m", "\x1b[23m"),
+ underline: init("\x1b[4m", "\x1b[24m"),
+ inverse: init("\x1b[7m", "\x1b[27m"),
+ hidden: init("\x1b[8m", "\x1b[28m"),
+ strikethrough: init("\x1b[9m", "\x1b[29m"),
+ black: init("\x1b[30m", "\x1b[39m"),
+ red: init("\x1b[31m", "\x1b[39m"),
+ green: init("\x1b[32m", "\x1b[39m"),
+ yellow: init("\x1b[33m", "\x1b[39m"),
+ blue: init("\x1b[34m", "\x1b[39m"),
+ magenta: init("\x1b[35m", "\x1b[39m"),
+ cyan: init("\x1b[36m", "\x1b[39m"),
+ white: init("\x1b[37m", "\x1b[39m"),
+ gray: init("\x1b[90m", "\x1b[39m"),
+ bgBlack: init("\x1b[40m", "\x1b[49m"),
+ bgRed: init("\x1b[41m", "\x1b[49m"),
+ bgGreen: init("\x1b[42m", "\x1b[49m"),
+ bgYellow: init("\x1b[43m", "\x1b[49m"),
+ bgBlue: init("\x1b[44m", "\x1b[49m"),
+ bgMagenta: init("\x1b[45m", "\x1b[49m"),
+ bgCyan: init("\x1b[46m", "\x1b[49m"),
+ bgWhite: init("\x1b[47m", "\x1b[49m"),
+ }
+}
module.exports = createColors()
module.exports.createColors = createColors