UNPKG

978 BJavaScriptView Raw
1"use strict";
2Object.defineProperty(exports, "__esModule", { value: true });
3exports.colors = exports.removeColor = exports.supportsColor = void 0;
4/**
5 * @license
6 * Copyright Google Inc. All Rights Reserved.
7 *
8 * Use of this source code is governed by an MIT-style license that can be
9 * found in the LICENSE file at https://angular.io/license
10 */
11const ansiColors = require("ansi-colors");
12const tty_1 = require("tty");
13// Typings do not contain the function call (added in Node.js v9.9.0)
14exports.supportsColor = process.stdout instanceof tty_1.WriteStream &&
15 process.stdout.getColorDepth() > 1;
16function removeColor(text) {
17 return text.replace(new RegExp(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
22const colors = ansiColors.create();
23exports.colors = colors;
24colors.enabled = exports.supportsColor;