You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

33 lines
972 B
JavaScript

"use strict";
const supportsColor = require("supports-color");
// NOTE: We do some manual ANSI escape code stuff here for now, because using `chalk` would significantly inflate the bundle size of the core.
// TODO: Find a better solution for this.
let openHighlight, openDim, openHighlightBold, openDimBold, closeColor;
if (supportsColor.stderr) {
openHighlight = `\u001b[32m`; // green
openDim = `\u001b[90m`; // gray
openHighlightBold = `\u001b[32;1m`; // green bold
openDimBold = `\u001b[90;1m`; // gray bold
// closeColor = `\u001b[39m`; // Does not reset bold!
closeColor = `\u001b[0m`;
} else {
openHighlight = "";
openDim = "";
openHighlightBold = "";
openDimBold = "";
closeColor = "";
}
module.exports = {
dim: (string) => openDim + string + closeColor,
highlight: (string) => openHighlight + string + closeColor,
dimBold: (string) => openDimBold + string + closeColor,
highlightBold: (string) => openHighlightBold + string + closeColor,
};