UNPKG

2.01 kBJavaScriptView Raw
1"use strict";
2Object.defineProperty(exports, "__esModule", { value: true });
3const ansiStyles = require("ansi-styles");
4const chalk = require("chalk");
5const supports = require("supports-color");
6const util_1 = require("util");
7const stripColor = (s) => {
8 return require('strip-ansi')(s);
9};
10const dim = process.env.ConEmuANSI === 'ON' ? chalk.gray : chalk.dim;
11exports.CustomColors = {
12 supports,
13 // map gray -> dim because it's not solarized compatible
14 gray: dim,
15 grey: dim,
16 dim,
17 attachment: chalk.cyan,
18 addon: chalk.yellow,
19 configVar: chalk.green,
20 release: chalk.blue.bold,
21 cmd: chalk.cyan.bold,
22 pipeline: chalk.green.bold,
23 // eslint-disable-next-line @typescript-eslint/no-use-before-define
24 app: (s) => chalk.level > 0 ? exports.color.heroku(`⬢ ${s}`) : s,
25 heroku: (s) => {
26 if (chalk.level === 0)
27 return s;
28 // eslint-disable-next-line @typescript-eslint/no-use-before-define
29 if (!exports.color.supports)
30 return s;
31 // eslint-disable-next-line @typescript-eslint/no-use-before-define
32 const has256 = exports.color.level >= 2 || (process.env.TERM || '').indexOf('256') !== -1;
33 return has256 ? '\u001b[38;5;104m' + s + ansiStyles.reset.open : chalk.magenta(s); // eslint-disable-line unicorn/escape-case
34 },
35 stripColor: util_1.deprecate(stripColor, '.stripColor is deprecated. Please import the "strip-ansi" module directly instead.'),
36};
37exports.color = new Proxy(chalk, {
38 get: (chalk, name) => {
39 if (exports.CustomColors[name])
40 return exports.CustomColors[name];
41 return chalk[name];
42 },
43 set: (chalk, name, value) => {
44 switch (name) {
45 case 'enabled':
46 if (!value)
47 chalk.level = 0;
48 break;
49 default:
50 throw new Error(`cannot set property ${name.toString()}`);
51 }
52 return true;
53 },
54});
55exports.default = exports.color;