MCPcopy
hub / github.com/dotenvx/dotenvx / getColor

Function getColor

src/shared/colors.js:36–54  ·  view source on GitHub ↗
(color)

Source from the content-addressed store, hash-verified

34])
35
36function getColor (color) {
37 const colorDepth = depth.getColorDepth()
38 if (!colors256.has(color)) {
39 throw new Errors({ color }).invalidColor()
40 }
41 if (colorDepth >= 24 && colorsTrueColor.has(color)) {
42 const [r, g, b] = colorsTrueColor.get(color)
43 return (message) => `\x1b[38;2;${r};${g};${b}m${message}\x1b[39m`
44 }
45 if (colorDepth >= 8) {
46 const code = colors256.get(color)
47 return (message) => `\x1b[38;5;${code}m${message}\x1b[39m`
48 }
49 if (colorDepth >= 4) {
50 const code = colors16.get(color)
51 return (message) => `\x1b[${code}m${message}\x1b[39m`
52 }
53 return (message) => message
54}
55
56function bold (message) {
57 if (depth.getColorDepth() >= 4) {

Callers 7

errorFunction · 0.85
logger.jsFile · 0.85
warnFunction · 0.85
successvFunction · 0.85
verboseFunction · 0.85
debugFunction · 0.85
colors.test.jsFile · 0.85

Calls 2

invalidColorMethod · 0.80
getMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…