UNPKG

1.1 kBJavaScriptView Raw
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 */
9Object.defineProperty(exports, "__esModule", { value: true });
10exports.colors = exports.removeColor = void 0;
11const ansiColors = require("ansi-colors");
12const tty_1 = require("tty");
13const supportsColor = process.stdout instanceof tty_1.WriteStream && process.stdout.getColorDepth() > 1;
14function removeColor(text) {
15 // This has been created because when colors.enabled is false unstyle doesn't work
16 // see: https://github.com/doowb/ansi-colors/blob/a4794363369d7b4d1872d248fc43a12761640d8e/index.js#L38
17 return text.replace(ansiColors.ansiRegex, '');
18}
19exports.removeColor = removeColor;
20// Create a separate instance to prevent unintended global changes to the color configuration
21// Create function is not defined in the typings. See: https://github.com/doowb/ansi-colors/pull/44
22const colors = ansiColors.create();
23exports.colors = colors;
24colors.enabled = supportsColor;