Rename stderr.supportsColor to supportsColorStderr
Signed-off-by: Richie Bendall <richiebendall@gmail.com>
This commit is contained in:
parent
427ea57355
commit
4c8f1ec52b
4 changed files with 14 additions and 12 deletions
2
index.d.ts
vendored
2
index.d.ts
vendored
|
|
@ -401,6 +401,8 @@ This simply means that `chalk.red.yellow.green` is equivalent to `chalk.green`.
|
||||||
declare const chalk: ChalkInstance & ChalkFunction;
|
declare const chalk: ChalkInstance & ChalkFunction;
|
||||||
|
|
||||||
export const supportsColor: ColorSupport | false;
|
export const supportsColor: ColorSupport | false;
|
||||||
|
|
||||||
export const chalkStderr: typeof chalk & {supportsColor: typeof supportsColor};
|
export const chalkStderr: typeof chalk & {supportsColor: typeof supportsColor};
|
||||||
|
export const supportsColorStderr: typeof supportsColor;
|
||||||
|
|
||||||
export default chalk;
|
export default chalk;
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
import {expectType, expectAssignable, expectError} from 'tsd';
|
import {expectType, expectAssignable, expectError} from 'tsd';
|
||||||
import chalk, {Chalk, ChalkInstance, Color, ColorSupport, ColorSupportLevel, chalkStderr, supportsColor} from './index.js';
|
import chalk, {Chalk, ChalkInstance, Color, ColorSupport, ColorSupportLevel, chalkStderr, supportsColor, supportsColorStderr} from './index.js';
|
||||||
|
|
||||||
// - Helpers -
|
// - Helpers -
|
||||||
type colorReturn = ChalkInstance & {supportsColor?: never};
|
type colorReturn = ChalkInstance & {supportsColor?: never};
|
||||||
|
|
@ -14,15 +14,15 @@ if (supportsColor) {
|
||||||
|
|
||||||
// - stderr -
|
// - stderr -
|
||||||
expectAssignable<ChalkInstance>(chalkStderr);
|
expectAssignable<ChalkInstance>(chalkStderr);
|
||||||
expectType<ColorSupport | false>(chalkStderr.supportsColor);
|
expectType<ColorSupport | false>(supportsColorStderr);
|
||||||
if (chalkStderr.supportsColor) {
|
if (supportsColorStderr) {
|
||||||
expectType<boolean>(chalkStderr.supportsColor.hasBasic);
|
expectType<boolean>(supportsColorStderr.hasBasic);
|
||||||
expectType<boolean>(chalkStderr.supportsColor.has256);
|
expectType<boolean>(supportsColorStderr.has256);
|
||||||
expectType<boolean>(chalkStderr.supportsColor.has16m);
|
expectType<boolean>(supportsColorStderr.has16m);
|
||||||
}
|
}
|
||||||
|
|
||||||
// -- `stderr` is not a member of the Chalk interface --
|
// -- `supportsColorStderr` is not a member of the Chalk interface --
|
||||||
expectError(chalk.reset.stderr);
|
expectError(chalk.reset.supportsColorStderr);
|
||||||
|
|
||||||
// -- `supportsColor` is not a member of the Chalk interface --
|
// -- `supportsColor` is not a member of the Chalk interface --
|
||||||
expectError(chalk.reset.supportsColor);
|
expectError(chalk.reset.supportsColor);
|
||||||
|
|
|
||||||
|
|
@ -191,9 +191,9 @@ Can be overridden by the user with the flags `--color` and `--no-color`. For sit
|
||||||
|
|
||||||
Explicit 256/Truecolor mode can be enabled using the `--color=256` and `--color=16m` flags, respectively.
|
Explicit 256/Truecolor mode can be enabled using the `--color=256` and `--color=16m` flags, respectively.
|
||||||
|
|
||||||
### chalkStderr and chalkStderr.supportsColor
|
### chalkStderr and supportsColorStderr
|
||||||
|
|
||||||
`chalkStderr` contains a separate instance configured with color support detected for `stderr` stream instead of `stdout`. Override rules from `supportsColor` apply to this too. `chalkStderr.supportsColor` is exposed for convenience.
|
`chalkStderr` contains a separate instance configured with color support detected for `stderr` stream instead of `stdout`. Override rules from `supportsColor` apply to this too. `supportsColorStderr` is exposed for convenience.
|
||||||
|
|
||||||
## Styles
|
## Styles
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -213,10 +213,10 @@ Object.defineProperties(createChalk.prototype, styles);
|
||||||
|
|
||||||
const chalk = createChalk();
|
const chalk = createChalk();
|
||||||
export const chalkStderr = createChalk({level: stderrColor ? stderrColor.level : 0});
|
export const chalkStderr = createChalk({level: stderrColor ? stderrColor.level : 0});
|
||||||
chalkStderr.supportsColor = stderrColor;
|
|
||||||
|
|
||||||
export {
|
export {
|
||||||
stdoutColor as supportsColor
|
stdoutColor as supportsColor,
|
||||||
|
stderrColor as supportsColorStderr
|
||||||
};
|
};
|
||||||
|
|
||||||
export default chalk;
|
export default chalk;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue