kleur
4.1.5 · 26 Jun 2022MIT176.8M / weekRepositoryHomepagenpmAtom feed
3.0.3 is the newest release of 3.x.
Release note
Breaking (#16)
This version is an intentional departure from the Chalk-like syntax. Any previous kleur chains (those with more than one color) will not work with 3.0 and will require slight changes. Most libraries can expect to update their usage within a few minutes!
// Before:
kleur.red.bold.underline('bolded, underlined, and red~!');
// After:
kleur.red().bold().underline('bolded, underlined, and red~!');However, should you prefer the old syntax, please consider using ansi-colors instead since (in most cases) it's a drop-in replacement for Chalk while staying significantly smaller and faster.
You can also replace kleur@2.x with ansi-colors without any code/syntax changes.
Important: The release of
kleur@3.0deprecates olderkleurversions.
Features
Named Chains & Partial Requires
It's now possible to save color-chains directly as variables!
// Before:
const kleur = require('kleur');
const toError = msg => kleur.white.bold.bgRed(msg);
toError('Oops');
// After:
const { white } = require('kleur'); // now possible
const toError = white().bold().bgRed;
toError('Oops');Detect Color Support (#13)
A (super) simple check for color support is now included, which sets the initial value for enabled.
Many libs attempt to toggle colors via
FORCE_COLORsince this ENV is used by Chalk.
See alsoNODE_DISABLE_COLORS.
const { FORCE_COLOR, NODE_DISABLE_COLORS, TERM } = process.env;
const $ = {
enabled: !NODE_DISABLE_COLORS && TERM !== 'dumb' && FORCE_COLOR !== '0'
};A whole project to check? Paste its package.json in the dependency check: every deprecated, outdated or vulnerable dependency, with what to upgrade to. Free, no account.