1 | "use strict";
|
---|
2 | /**
|
---|
3 | * @license
|
---|
4 | * Copyright Google LLC All Rights Reserved.
|
---|
5 | *
|
---|
6 | * Use of this source code is governed by an MIT-style license that can be
|
---|
7 | * found in the LICENSE file at https://angular.io/license
|
---|
8 | */
|
---|
9 | var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
---|
10 | if (k2 === undefined) k2 = k;
|
---|
11 | Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
---|
12 | }) : (function(o, m, k, k2) {
|
---|
13 | if (k2 === undefined) k2 = k;
|
---|
14 | o[k2] = m[k];
|
---|
15 | }));
|
---|
16 | var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
---|
17 | Object.defineProperty(o, "default", { enumerable: true, value: v });
|
---|
18 | }) : function(o, v) {
|
---|
19 | o["default"] = v;
|
---|
20 | });
|
---|
21 | var __importStar = (this && this.__importStar) || function (mod) {
|
---|
22 | if (mod && mod.__esModule) return mod;
|
---|
23 | var result = {};
|
---|
24 | if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
---|
25 | __setModuleDefault(result, mod);
|
---|
26 | return result;
|
---|
27 | };
|
---|
28 | Object.defineProperty(exports, "__esModule", { value: true });
|
---|
29 | exports.colors = exports.removeColor = void 0;
|
---|
30 | const ansiColors = __importStar(require("ansi-colors"));
|
---|
31 | const tty_1 = require("tty");
|
---|
32 | function supportColor() {
|
---|
33 | if (process.env.FORCE_COLOR !== undefined) {
|
---|
34 | // 2 colors: FORCE_COLOR = 0 (Disables colors), depth 1
|
---|
35 | // 16 colors: FORCE_COLOR = 1, depth 4
|
---|
36 | // 256 colors: FORCE_COLOR = 2, depth 8
|
---|
37 | // 16,777,216 colors: FORCE_COLOR = 3, depth 16
|
---|
38 | // See: https://nodejs.org/dist/latest-v12.x/docs/api/tty.html#tty_writestream_getcolordepth_env
|
---|
39 | // and https://github.com/nodejs/node/blob/b9f36062d7b5c5039498e98d2f2c180dca2a7065/lib/internal/tty.js#L106;
|
---|
40 | switch (process.env.FORCE_COLOR) {
|
---|
41 | case '':
|
---|
42 | case 'true':
|
---|
43 | case '1':
|
---|
44 | case '2':
|
---|
45 | case '3':
|
---|
46 | return true;
|
---|
47 | default:
|
---|
48 | return false;
|
---|
49 | }
|
---|
50 | }
|
---|
51 | if (process.stdout instanceof tty_1.WriteStream) {
|
---|
52 | return process.stdout.getColorDepth() > 1;
|
---|
53 | }
|
---|
54 | return false;
|
---|
55 | }
|
---|
56 | function removeColor(text) {
|
---|
57 | // This has been created because when colors.enabled is false unstyle doesn't work
|
---|
58 | // see: https://github.com/doowb/ansi-colors/blob/a4794363369d7b4d1872d248fc43a12761640d8e/index.js#L38
|
---|
59 | return text.replace(ansiColors.ansiRegex, '');
|
---|
60 | }
|
---|
61 | exports.removeColor = removeColor;
|
---|
62 | // Create a separate instance to prevent unintended global changes to the color configuration
|
---|
63 | // Create function is not defined in the typings. See: https://github.com/doowb/ansi-colors/pull/44
|
---|
64 | const colors = ansiColors.create();
|
---|
65 | exports.colors = colors;
|
---|
66 | colors.enabled = supportColor();
|
---|