Sha256: c3e69887f23ab990b3bc8db4e09853ec0539c2480aed328c430ccc2127001160

Contents?: true

Size: 1.48 KB

Versions: 25

Compression:

Stored size: 1.48 KB

Contents

let FORCE_COLOR, NODE_DISABLE_COLORS, NO_COLOR, TERM, isTTY=true;
if (typeof process !== 'undefined') {
	({ FORCE_COLOR, NODE_DISABLE_COLORS, NO_COLOR, TERM } = process.env || {});
	isTTY = process.stdout && process.stdout.isTTY;
}

const $ = exports.$ = {
	enabled: !NODE_DISABLE_COLORS && NO_COLOR == null && TERM !== 'dumb' && (
		FORCE_COLOR != null && FORCE_COLOR !== '0' || isTTY
	)
}

function init(x, y) {
	let rgx = new RegExp(`\\x1b\\[${y}m`, 'g');
	let open = `\x1b[${x}m`, close = `\x1b[${y}m`;

	return function (txt) {
		if (!$.enabled || txt == null) return txt;
		return open + (!!~(''+txt).indexOf(close) ? txt.replace(rgx, close + open) : txt) + close;
	};
}

// modifiers
exports.reset = init(0, 0);
exports.bold = init(1, 22);
exports.dim = init(2, 22);
exports.italic = init(3, 23);
exports.underline = init(4, 24);
exports.inverse = init(7, 27);
exports.hidden = init(8, 28);
exports.strikethrough = init(9, 29);

// colors
exports.black = init(30, 39);
exports.red = init(31, 39);
exports.green = init(32, 39);
exports.yellow = init(33, 39);
exports.blue = init(34, 39);
exports.magenta = init(35, 39);
exports.cyan = init(36, 39);
exports.white = init(37, 39);
exports.gray = init(90, 39);
exports.grey = init(90, 39);

// background colors
exports.bgBlack = init(40, 49);
exports.bgRed = init(41, 49);
exports.bgGreen = init(42, 49);
exports.bgYellow = init(43, 49);
exports.bgBlue = init(44, 49);
exports.bgMagenta = init(45, 49);
exports.bgCyan = init(46, 49);
exports.bgWhite = init(47, 49);

Version data entries

25 entries across 25 versions & 1 rubygems

Version Path
immosquare-cleaner-0.1.52 node_modules/kleur/colors.js
immosquare-cleaner-0.1.51 node_modules/kleur/colors.js
immosquare-cleaner-0.1.50 node_modules/kleur/colors.js
immosquare-cleaner-0.1.49 node_modules/kleur/colors.js
immosquare-cleaner-0.1.48 node_modules/kleur/colors.js
immosquare-cleaner-0.1.47 node_modules/kleur/colors.js
immosquare-cleaner-0.1.46 node_modules/kleur/colors.js
immosquare-cleaner-0.1.45 node_modules/kleur/colors.js
immosquare-cleaner-0.1.44 node_modules/kleur/colors.js
immosquare-cleaner-0.1.43 node_modules/kleur/colors.js
immosquare-cleaner-0.1.42 node_modules/kleur/colors.js
immosquare-cleaner-0.1.41 node_modules/kleur/colors.js
immosquare-cleaner-0.1.40 node_modules/kleur/colors.js
immosquare-cleaner-0.1.39 node_modules/kleur/colors.js
immosquare-cleaner-0.1.38 node_modules/kleur/colors.js
immosquare-cleaner-0.1.32 node_modules/kleur/colors.js
immosquare-cleaner-0.1.31 node_modules/kleur/colors.js
immosquare-cleaner-0.1.30 node_modules/kleur/colors.js
immosquare-cleaner-0.1.29 node_modules/kleur/colors.js
immosquare-cleaner-0.1.28 node_modules/kleur/colors.js