Skip to content

v3.0.0

Compare
Choose a tag to compare
@lukeed lukeed released this 15 Nov 21:38
· 56 commits to master since this release

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 [email protected] with ansi-colors without any code/syntax changes.

Important: The release of [email protected] deprecates older kleur versions.

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_COLOR since this ENV is used by Chalk.
See also NODE_DISABLE_COLORS.

const { FORCE_COLOR, NODE_DISABLE_COLORS, TERM } = process.env;

const $ = {
  enabled: !NODE_DISABLE_COLORS && TERM !== 'dumb' && FORCE_COLOR !== '0'
};