Update dependencies

This commit is contained in:
Sindre Sorhus 2019-07-12 13:59:50 +07:00
parent 655653bb0c
commit c25c32a25f
7 changed files with 56 additions and 30 deletions

20
index.d.ts vendored
View file

@ -261,8 +261,17 @@ declare namespace chalk {
readonly magenta: Chalk; readonly magenta: Chalk;
readonly cyan: Chalk; readonly cyan: Chalk;
readonly white: Chalk; readonly white: Chalk;
/*
Alias for `blackBright`.
*/
readonly gray: Chalk; readonly gray: Chalk;
/*
Alias for `blackBright`.
*/
readonly grey: Chalk; readonly grey: Chalk;
readonly blackBright: Chalk; readonly blackBright: Chalk;
readonly redBright: Chalk; readonly redBright: Chalk;
readonly greenBright: Chalk; readonly greenBright: Chalk;
@ -280,6 +289,17 @@ declare namespace chalk {
readonly bgMagenta: Chalk; readonly bgMagenta: Chalk;
readonly bgCyan: Chalk; readonly bgCyan: Chalk;
readonly bgWhite: Chalk; readonly bgWhite: Chalk;
/*
Alias for `bgBlackBright`.
*/
readonly bgGray: Chalk;
/*
Alias for `bgBlackBright`.
*/
readonly bgGrey: Chalk;
readonly bgBlackBright: Chalk; readonly bgBlackBright: Chalk;
readonly bgRedBright: Chalk; readonly bgRedBright: Chalk;
readonly bgGreenBright: Chalk; readonly bgGreenBright: Chalk;

View file

@ -40,18 +40,18 @@
"text" "text"
], ],
"dependencies": { "dependencies": {
"ansi-styles": "^3.2.1", "ansi-styles": "^4.0.0",
"supports-color": "^6.1.0" "supports-color": "^7.0.0"
}, },
"devDependencies": { "devDependencies": {
"ava": "^1.4.1", "ava": "^2.2.0",
"coveralls": "^3.0.3", "coveralls": "^3.0.5",
"execa": "^1.0.0", "execa": "^2.0.3",
"import-fresh": "^3.0.0", "import-fresh": "^3.1.0",
"matcha": "^0.7.0", "matcha": "^0.7.0",
"nyc": "^14.0.0", "nyc": "^14.1.1",
"resolve-from": "^5.0.0", "resolve-from": "^5.0.0",
"tsd": "^0.7.2", "tsd": "^0.7.4",
"xo": "^0.24.0" "xo": "^0.24.0"
} }
} }

View file

@ -13,6 +13,8 @@
<img src="https://cdn.jsdelivr.net/gh/chalk/ansi-styles@8261697c95bf34b6c7767e2cbe9941a851d59385/screenshot.svg" width="900"> <img src="https://cdn.jsdelivr.net/gh/chalk/ansi-styles@8261697c95bf34b6c7767e2cbe9941a851d59385/screenshot.svg" width="900">
**This readme reflects the next major version that is currently in development. You probably want [the v2 readme](https://www.npmjs.com/package/chalk).**
## Highlights ## Highlights
@ -180,7 +182,7 @@ Explicit 256/Truecolor mode can be enabled using the `--color=256` and `--color=
- `magenta` - `magenta`
- `cyan` - `cyan`
- `white` - `white`
- `gray` ("bright black") - `blackBright` (alias: `gray`, `grey`)
- `redBright` - `redBright`
- `greenBright` - `greenBright`
- `yellowBright` - `yellowBright`
@ -199,7 +201,7 @@ Explicit 256/Truecolor mode can be enabled using the `--color=256` and `--color=
- `bgMagenta` - `bgMagenta`
- `bgCyan` - `bgCyan`
- `bgWhite` - `bgWhite`
- `bgBlackBright` - `bgBlackBright` (alias: `bgGray`, `bgGrey`)
- `bgRedBright` - `bgRedBright`
- `bgGreenBright` - `bgGreenBright`
- `bgYellowBright` - `bgYellowBright`

View file

@ -193,10 +193,9 @@ const applyStyle = (self, string) => {
} }
} }
// We can move both next actions out of loop, because remaining actions in loop won't have any/visible effect on parts we add here // We can move both next actions out of loop, because remaining actions in loop won't have
// Close the styling before a linebreak and reopen // any/visible effect on parts we add here. Close the styling before a linebreak and reopen
// after next line to fix a bleed issue on macOS // after next line to fix a bleed issue on macOS: https://github.com/chalk/chalk/pull/92
// https://github.com/chalk/chalk/pull/92
const lfIndex = string.indexOf('\n'); const lfIndex = string.indexOf('\n');
if (lfIndex !== -1) { if (lfIndex !== -1) {
string = stringEncaseCRLFWithFirstIndex(string, closeAll, openAll, lfIndex); string = stringEncaseCRLFWithFirstIndex(string, closeAll, openAll, lfIndex);

View file

@ -6,31 +6,31 @@ const stringReplaceAll = (string, substring, replacer) => {
return string; return string;
} }
const subLen = substring.length; const substringLength = substring.length;
let end = 0; let endIndex = 0;
let res = ''; let returnValue = '';
do { do {
res += string.substr(end, index - end) + replacer; returnValue += string.substr(endIndex, index - endIndex) + replacer;
end = index + subLen; endIndex = index + substringLength;
index = string.indexOf(substring, end); index = string.indexOf(substring, endIndex);
} while (index !== -1); } while (index !== -1);
res += string.substr(end); returnValue += string.substr(endIndex);
return res; return returnValue;
}; };
const stringEncaseCRLFWithFirstIndex = (string, prefix, postfix, index) => { const stringEncaseCRLFWithFirstIndex = (string, prefix, postfix, index) => {
let end = 0; let endIndex = 0;
let res = ''; let returnValue = '';
do { do {
const gotCR = string[index - 1] === '\r'; const gotCR = string[index - 1] === '\r';
res += string.substr(end, (gotCR ? index - 1 : index) - end) + prefix + (gotCR ? '\r\n' : '\n') + postfix; returnValue += string.substr(endIndex, (gotCR ? index - 1 : index) - endIndex) + prefix + (gotCR ? '\r\n' : '\n') + postfix;
end = index + 1; endIndex = index + 1;
index = string.indexOf('\n', end); index = string.indexOf('\n', endIndex);
} while (index !== -1); } while (index !== -1);
res += string.substr(end); returnValue += string.substr(endIndex);
return res; return returnValue;
}; };
module.exports = { module.exports = {

View file

@ -101,3 +101,7 @@ test('don\'t emit RGB codes if level is 0', t => {
t.is(new chalk.Instance({level: 0}).hex('#FF0000')('hello'), 'hello'); t.is(new chalk.Instance({level: 0}).hex('#FF0000')('hello'), 'hello');
t.is(new chalk.Instance({level: 0}).bgHex('#FF0000')('hello'), 'hello'); t.is(new chalk.Instance({level: 0}).bgHex('#FF0000')('hello'), 'hello');
}); });
test('supports blackBright color', t => {
t.is(chalk.blackBright('foo'), '\u001B[90mfoo\u001B[39m');
});

View file

@ -40,5 +40,6 @@ test('propagate enable/disable changes from child colors', t => {
}); });
test('disable colors if they are not supported', async t => { test('disable colors if they are not supported', async t => {
t.is(await execa.stdout('node', [path.join(__dirname, '_fixture')]), 'test'); const {stdout} = await execa.node(path.join(__dirname, '_fixture'));
t.is(stdout, 'test');
}); });