Update test dependencies (#414)
This commit is contained in:
parent
b31d6fb48a
commit
c0d8e7ed8a
7 changed files with 49 additions and 47 deletions
|
|
@ -3,7 +3,9 @@ const chalk = require('..');
|
|||
|
||||
const ignoreChars = /[^!-~]/g;
|
||||
|
||||
const delay = milliseconds => new Promise(resolve => setTimeout(resolve, milliseconds));
|
||||
const delay = milliseconds => new Promise(resolve => {
|
||||
setTimeout(resolve, milliseconds);
|
||||
});
|
||||
|
||||
function rainbow(string, offset) {
|
||||
if (!string || string.length === 0) {
|
||||
|
|
|
|||
32
index.d.ts
vendored
32
index.d.ts
vendored
|
|
@ -181,7 +181,7 @@ declare namespace chalk {
|
|||
chalk.hex('#DEADED');
|
||||
```
|
||||
*/
|
||||
hex(color: string): Chalk;
|
||||
hex: (color: string) => Chalk;
|
||||
|
||||
/**
|
||||
Use keyword color value to set text color.
|
||||
|
|
@ -195,27 +195,27 @@ declare namespace chalk {
|
|||
chalk.keyword('orange');
|
||||
```
|
||||
*/
|
||||
keyword(color: string): Chalk;
|
||||
keyword: (color: string) => Chalk;
|
||||
|
||||
/**
|
||||
Use RGB values to set text color.
|
||||
*/
|
||||
rgb(red: number, green: number, blue: number): Chalk;
|
||||
rgb: (red: number, green: number, blue: number) => Chalk;
|
||||
|
||||
/**
|
||||
Use HSL values to set text color.
|
||||
*/
|
||||
hsl(hue: number, saturation: number, lightness: number): Chalk;
|
||||
hsl: (hue: number, saturation: number, lightness: number) => Chalk;
|
||||
|
||||
/**
|
||||
Use HSV values to set text color.
|
||||
*/
|
||||
hsv(hue: number, saturation: number, value: number): Chalk;
|
||||
hsv: (hue: number, saturation: number, value: number) => Chalk;
|
||||
|
||||
/**
|
||||
Use HWB values to set text color.
|
||||
*/
|
||||
hwb(hue: number, whiteness: number, blackness: number): Chalk;
|
||||
hwb: (hue: number, whiteness: number, blackness: number) => Chalk;
|
||||
|
||||
/**
|
||||
Use a [Select/Set Graphic Rendition](https://en.wikipedia.org/wiki/ANSI_escape_code#SGR_parameters) (SGR) [color code number](https://en.wikipedia.org/wiki/ANSI_escape_code#3/4_bit) to set text color.
|
||||
|
|
@ -223,12 +223,12 @@ declare namespace chalk {
|
|||
30 <= code && code < 38 || 90 <= code && code < 98
|
||||
For example, 31 for red, 91 for redBright.
|
||||
*/
|
||||
ansi(code: number): Chalk;
|
||||
ansi: (code: number) => Chalk;
|
||||
|
||||
/**
|
||||
Use a [8-bit unsigned number](https://en.wikipedia.org/wiki/ANSI_escape_code#8-bit) to set text color.
|
||||
*/
|
||||
ansi256(index: number): Chalk;
|
||||
ansi256: (index: number) => Chalk;
|
||||
|
||||
/**
|
||||
Use HEX value to set background color.
|
||||
|
|
@ -242,7 +242,7 @@ declare namespace chalk {
|
|||
chalk.bgHex('#DEADED');
|
||||
```
|
||||
*/
|
||||
bgHex(color: string): Chalk;
|
||||
bgHex: (color: string) => Chalk;
|
||||
|
||||
/**
|
||||
Use keyword color value to set background color.
|
||||
|
|
@ -256,27 +256,27 @@ declare namespace chalk {
|
|||
chalk.bgKeyword('orange');
|
||||
```
|
||||
*/
|
||||
bgKeyword(color: string): Chalk;
|
||||
bgKeyword: (color: string) => Chalk;
|
||||
|
||||
/**
|
||||
Use RGB values to set background color.
|
||||
*/
|
||||
bgRgb(red: number, green: number, blue: number): Chalk;
|
||||
bgRgb: (red: number, green: number, blue: number) => Chalk;
|
||||
|
||||
/**
|
||||
Use HSL values to set background color.
|
||||
*/
|
||||
bgHsl(hue: number, saturation: number, lightness: number): Chalk;
|
||||
bgHsl: (hue: number, saturation: number, lightness: number) => Chalk;
|
||||
|
||||
/**
|
||||
Use HSV values to set background color.
|
||||
*/
|
||||
bgHsv(hue: number, saturation: number, value: number): Chalk;
|
||||
bgHsv: (hue: number, saturation: number, value: number) => Chalk;
|
||||
|
||||
/**
|
||||
Use HWB values to set background color.
|
||||
*/
|
||||
bgHwb(hue: number, whiteness: number, blackness: number): Chalk;
|
||||
bgHwb: (hue: number, whiteness: number, blackness: number) => Chalk;
|
||||
|
||||
/**
|
||||
Use a [Select/Set Graphic Rendition](https://en.wikipedia.org/wiki/ANSI_escape_code#SGR_parameters) (SGR) [color code number](https://en.wikipedia.org/wiki/ANSI_escape_code#3/4_bit) to set background color.
|
||||
|
|
@ -285,12 +285,12 @@ declare namespace chalk {
|
|||
For example, 31 for red, 91 for redBright.
|
||||
Use the foreground code, not the background code (for example, not 41, nor 101).
|
||||
*/
|
||||
bgAnsi(code: number): Chalk;
|
||||
bgAnsi: (code: number) => Chalk;
|
||||
|
||||
/**
|
||||
Use a [8-bit unsigned number](https://en.wikipedia.org/wiki/ANSI_escape_code#8-bit) to set background color.
|
||||
*/
|
||||
bgAnsi256(index: number): Chalk;
|
||||
bgAnsi256: (index: number) => Chalk;
|
||||
|
||||
/**
|
||||
Modifier: Resets the current color chain.
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import {expectType, expectError} from 'tsd';
|
||||
import {expectType, expectAssignable, expectError} from 'tsd';
|
||||
import chalk = require('.');
|
||||
|
||||
// - Helpers -
|
||||
|
|
@ -13,7 +13,7 @@ if (chalk.supportsColor) {
|
|||
}
|
||||
|
||||
// - stderr -
|
||||
expectType<chalk.Chalk>(chalk.stderr);
|
||||
expectAssignable<chalk.Chalk>(chalk.stderr);
|
||||
expectType<chalk.ColorSupport | false>(chalk.stderr.supportsColor);
|
||||
if (chalk.stderr.supportsColor) {
|
||||
expectType<boolean>(chalk.stderr.supportsColor.hasBasic);
|
||||
|
|
@ -41,22 +41,22 @@ expectType<string>(chalk`Hello {bold.red ${name}}`);
|
|||
expectType<string>(chalk`Works with numbers {bold.red ${1}}`);
|
||||
|
||||
// -- Color methods --
|
||||
expectType<colorReturn>(chalk.hex('#DEADED'));
|
||||
expectType<colorReturn>(chalk.keyword('orange'));
|
||||
expectType<colorReturn>(chalk.rgb(0, 0, 0));
|
||||
expectType<colorReturn>(chalk.hsl(0, 0, 0));
|
||||
expectType<colorReturn>(chalk.hsv(0, 0, 0));
|
||||
expectType<colorReturn>(chalk.hwb(0, 0, 0));
|
||||
expectType<colorReturn>(chalk.ansi(30));
|
||||
expectType<colorReturn>(chalk.ansi256(0));
|
||||
expectType<colorReturn>(chalk.bgHex('#DEADED'));
|
||||
expectType<colorReturn>(chalk.bgKeyword('orange'));
|
||||
expectType<colorReturn>(chalk.bgRgb(0, 0, 0));
|
||||
expectType<colorReturn>(chalk.bgHsl(0, 0, 0));
|
||||
expectType<colorReturn>(chalk.bgHsv(0, 0, 0));
|
||||
expectType<colorReturn>(chalk.bgHwb(0, 0, 0));
|
||||
expectType<colorReturn>(chalk.bgAnsi(30));
|
||||
expectType<colorReturn>(chalk.bgAnsi256(0));
|
||||
expectAssignable<colorReturn>(chalk.hex('#DEADED'));
|
||||
expectAssignable<colorReturn>(chalk.keyword('orange'));
|
||||
expectAssignable<colorReturn>(chalk.rgb(0, 0, 0));
|
||||
expectAssignable<colorReturn>(chalk.hsl(0, 0, 0));
|
||||
expectAssignable<colorReturn>(chalk.hsv(0, 0, 0));
|
||||
expectAssignable<colorReturn>(chalk.hwb(0, 0, 0));
|
||||
expectAssignable<colorReturn>(chalk.ansi(30));
|
||||
expectAssignable<colorReturn>(chalk.ansi256(0));
|
||||
expectAssignable<colorReturn>(chalk.bgHex('#DEADED'));
|
||||
expectAssignable<colorReturn>(chalk.bgKeyword('orange'));
|
||||
expectAssignable<colorReturn>(chalk.bgRgb(0, 0, 0));
|
||||
expectAssignable<colorReturn>(chalk.bgHsl(0, 0, 0));
|
||||
expectAssignable<colorReturn>(chalk.bgHsv(0, 0, 0));
|
||||
expectAssignable<colorReturn>(chalk.bgHwb(0, 0, 0));
|
||||
expectAssignable<colorReturn>(chalk.bgAnsi(30));
|
||||
expectAssignable<colorReturn>(chalk.bgAnsi256(0));
|
||||
|
||||
// -- Modifiers --
|
||||
expectType<string>(chalk.reset('foo'));
|
||||
|
|
@ -158,5 +158,5 @@ expectType<string>(chalk.red.bgGreen.bold`Hello {italic.blue ${name}}`);
|
|||
expectType<string>(chalk.strikethrough.cyanBright.bgBlack`Works with {reset {bold numbers}} {bold.red ${1}}`);
|
||||
|
||||
// -- Color types ==
|
||||
expectType<typeof chalk.Color>('red');
|
||||
expectAssignable<typeof chalk.Color>('red');
|
||||
expectError<typeof chalk.Color>('hotpink');
|
||||
|
|
|
|||
12
package.json
12
package.json
|
|
@ -46,14 +46,14 @@
|
|||
},
|
||||
"devDependencies": {
|
||||
"ava": "^2.4.0",
|
||||
"coveralls": "^3.0.7",
|
||||
"execa": "^4.0.0",
|
||||
"import-fresh": "^3.1.0",
|
||||
"coveralls": "^3.1.0",
|
||||
"execa": "^4.0.3",
|
||||
"import-fresh": "^3.2.1",
|
||||
"matcha": "^0.7.0",
|
||||
"nyc": "^15.0.0",
|
||||
"nyc": "^15.1.0",
|
||||
"resolve-from": "^5.0.0",
|
||||
"tsd": "^0.7.4",
|
||||
"xo": "^0.28.2"
|
||||
"tsd": "^0.13.1",
|
||||
"xo": "^0.33.1"
|
||||
},
|
||||
"xo": {
|
||||
"rules": {
|
||||
|
|
|
|||
|
|
@ -22,11 +22,11 @@ function unescape(c) {
|
|||
const bracket = c[1] === '{';
|
||||
|
||||
if ((u && !bracket && c.length === 5) || (c[0] === 'x' && c.length === 3)) {
|
||||
return String.fromCharCode(parseInt(c.slice(1), 16));
|
||||
return String.fromCharCode(Number.parseInt(c.slice(1), 16));
|
||||
}
|
||||
|
||||
if (u && bracket) {
|
||||
return String.fromCodePoint(parseInt(c.slice(2, -1), 16));
|
||||
return String.fromCodePoint(Number.parseInt(c.slice(2, -1), 16));
|
||||
}
|
||||
|
||||
return ESCAPES.get(c) || c;
|
||||
|
|
|
|||
|
|
@ -17,10 +17,10 @@ test('the `level` option should be a number from 0 to 3', t => {
|
|||
/* eslint-disable no-new */
|
||||
t.throws(() => {
|
||||
new chalk.Instance({level: 10});
|
||||
}, /should be an integer from 0 to 3/);
|
||||
}, {message: /should be an integer from 0 to 3/});
|
||||
|
||||
t.throws(() => {
|
||||
new chalk.Instance({level: -1});
|
||||
}, /should be an integer from 0 to 3/);
|
||||
}, {message: /should be an integer from 0 to 3/});
|
||||
/* eslint-enable no-new */
|
||||
});
|
||||
|
|
|
|||
|
|
@ -179,7 +179,7 @@ test('throws if an extra unescaped } is found', t => {
|
|||
|
||||
test('should not parse upper-case escapes', t => {
|
||||
const instance = new chalk.Instance({level: 0});
|
||||
t.is(instance`\N\n\T\t\X07\x07\U000A\u000A\U000a\u000a`, 'N\nT\tX07\x07U000A\u000AU000a\u000A');
|
||||
t.is(instance`\N\n\T\t\X07\x07\U000A\u000A\U000a\u000A`, 'N\nT\tX07\x07U000A\u000AU000a\u000A');
|
||||
});
|
||||
|
||||
test('should properly handle undefined template interpolated values', t => {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue