UNPKG

2.43 kBJavaScriptView Raw
1"use strict";
2var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3 if (k2 === undefined) k2 = k;
4 var desc = Object.getOwnPropertyDescriptor(m, k);
5 if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6 desc = { enumerable: true, get: function() { return m[k]; } };
7 }
8 Object.defineProperty(o, k2, desc);
9}) : (function(o, m, k, k2) {
10 if (k2 === undefined) k2 = k;
11 o[k2] = m[k];
12}));
13var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14 Object.defineProperty(o, "default", { enumerable: true, value: v });
15}) : function(o, v) {
16 o["default"] = v;
17});
18var __importStar = (this && this.__importStar) || function (mod) {
19 if (mod && mod.__esModule) return mod;
20 var result = {};
21 if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22 __setModuleDefault(result, mod);
23 return result;
24};
25Object.defineProperty(exports, "__esModule", { value: true });
26exports.colors = void 0;
27const ansiColors = __importStar(require("ansi-colors"));
28const tty_1 = require("tty");
29function supportColor() {
30 if (process.env.FORCE_COLOR !== undefined) {
31 // 2 colors: FORCE_COLOR = 0 (Disables colors), depth 1
32 // 16 colors: FORCE_COLOR = 1, depth 4
33 // 256 colors: FORCE_COLOR = 2, depth 8
34 // 16,777,216 colors: FORCE_COLOR = 3, depth 16
35 // See: https://nodejs.org/dist/latest-v12.x/docs/api/tty.html#tty_writestream_getcolordepth_env
36 // and https://github.com/nodejs/node/blob/b9f36062d7b5c5039498e98d2f2c180dca2a7065/lib/internal/tty.js#L106;
37 switch (process.env.FORCE_COLOR) {
38 case '':
39 case 'true':
40 case '1':
41 case '2':
42 case '3':
43 return true;
44 default:
45 return false;
46 }
47 }
48 if (process.stdout instanceof tty_1.WriteStream) {
49 return process.stdout.getColorDepth() > 1;
50 }
51 return false;
52}
53// Create a separate instance to prevent unintended global changes to the color configuration
54// Create function is not defined in the typings. See: https://github.com/doowb/ansi-colors/pull/44
55const colors = ansiColors.create();
56exports.colors = colors;
57colors.enabled = supportColor();
58//# sourceMappingURL=color.js.map
\No newline at end of file