Add types field to package.json

Fixes #500
This commit is contained in:
Sindre Sorhus 2021-07-30 17:30:19 +02:00
parent 48d25d156a
commit 625a285772
9 changed files with 41 additions and 39 deletions

View file

@ -20,7 +20,7 @@ test('support automatic casting to string', t => {
t.is(chalk(123), '123');
t.is(chalk.bold(['foo', 'bar']), '\u001B[1mfoo,bar\u001B[22m');
t.is(chalk.green(98765), '\u001B[32m98765\u001B[39m');
t.is(chalk.green(98_765), '\u001B[32m98765\u001B[39m');
});
test('style string', t => {
@ -37,14 +37,14 @@ test('support applying multiple styles at once', t => {
test('support nesting styles', t => {
t.is(
chalk.red('foo' + chalk.underline.bgBlue('bar') + '!'),
'\u001B[31mfoo\u001B[4m\u001B[44mbar\u001B[49m\u001B[24m!\u001B[39m'
'\u001B[31mfoo\u001B[4m\u001B[44mbar\u001B[49m\u001B[24m!\u001B[39m',
);
});
test('support nesting styles of the same type (color, underline, bg)', t => {
t.is(
chalk.red('a' + chalk.yellow('b' + chalk.green('c') + 'b') + 'c'),
'\u001B[31ma\u001B[33mb\u001B[32mc\u001B[39m\u001B[31m\u001B[33mb\u001B[39m\u001B[31mc\u001B[39m'
'\u001B[31ma\u001B[33mb\u001B[32mc\u001B[39m\u001B[31m\u001B[33mb\u001B[39m\u001B[31mc\u001B[39m',
);
});

View file

@ -1,4 +1,4 @@
import {fileURLToPath} from 'url';
import {fileURLToPath} from 'node:url';
import test from 'ava';
import execa from 'execa';
import chalk from '../source/index.js';

View file

@ -42,22 +42,22 @@ test('correctly perform nested template substitutions', t => {
instance.strikethrough.cyanBright.bgBlack('Works with ' + instance.reset.bold('numbers') + ' ' + instance.bold.red(1)));
t.is(chalk.bold`Also works on the shared {bgBlue chalk} object`,
'\u001B[1mAlso works on the shared \u001B[1m' +
'\u001B[44mchalk\u001B[49m\u001B[22m' +
'\u001B[1m object\u001B[22m');
'\u001B[1mAlso works on the shared \u001B[1m'
+ '\u001B[44mchalk\u001B[49m\u001B[22m'
+ '\u001B[1m object\u001B[22m');
});
test('correctly parse and evaluate color-convert functions', t => {
const instance = new Chalk({level: 3});
t.is(instance`{bold.rgb(144,10,178).inverse Hello, {~inverse there!}}`,
'\u001B[1m\u001B[38;2;144;10;178m\u001B[7mHello, ' +
'\u001B[27m\u001B[39m\u001B[22m\u001B[1m' +
'\u001B[38;2;144;10;178mthere!\u001B[39m\u001B[22m');
'\u001B[1m\u001B[38;2;144;10;178m\u001B[7mHello, '
+ '\u001B[27m\u001B[39m\u001B[22m\u001B[1m'
+ '\u001B[38;2;144;10;178mthere!\u001B[39m\u001B[22m');
t.is(instance`{bold.bgRgb(144,10,178).inverse Hello, {~inverse there!}}`,
'\u001B[1m\u001B[48;2;144;10;178m\u001B[7mHello, ' +
'\u001B[27m\u001B[49m\u001B[22m\u001B[1m' +
'\u001B[48;2;144;10;178mthere!\u001B[49m\u001B[22m');
'\u001B[1m\u001B[48;2;144;10;178m\u001B[7mHello, '
+ '\u001B[27m\u001B[49m\u001B[22m\u001B[1m'
+ '\u001B[48;2;144;10;178mthere!\u001B[49m\u001B[22m');
});
test('properly handle escapes', t => {
@ -103,13 +103,13 @@ test('properly style multiline color blocks', t => {
} {underline
I hope you enjoy
}`,
'\u001B[1m\u001B[22m\n' +
'\u001B[1m\t\t\tHello! This is a\u001B[22m\n' +
'\u001B[1m\t\t\tmultiline block!\u001B[22m\n' +
'\u001B[1m\t\t\t:)\u001B[22m\n' +
'\u001B[1m\t\t\u001B[22m \u001B[4m\u001B[24m\n' +
'\u001B[4m\t\t\tI hope you enjoy\u001B[24m\n' +
'\u001B[4m\t\t\u001B[24m'
'\u001B[1m\u001B[22m\n'
+ '\u001B[1m\t\t\tHello! This is a\u001B[22m\n'
+ '\u001B[1m\t\t\tmultiline block!\u001B[22m\n'
+ '\u001B[1m\t\t\t:)\u001B[22m\n'
+ '\u001B[1m\t\t\u001B[22m \u001B[4m\u001B[24m\n'
+ '\u001B[4m\t\t\tI hope you enjoy\u001B[24m\n'
+ '\u001B[4m\t\t\u001B[24m',
);
});