forked from orbit-oss/chalk
Add chalk.stderr (#359)
This commit is contained in:
parent
6b4d20683f
commit
2a53389d72
9 changed files with 47 additions and 9 deletions
|
|
@ -1,4 +1,4 @@
|
|||
'use strict';
|
||||
const chalk = require('../source');
|
||||
|
||||
console.log(chalk.hex('#ff6159')('test'));
|
||||
console.log(`${chalk.hex('#ff6159')('testout')} ${chalk.stderr.hex('#ff6159')('testerr')}`);
|
||||
|
|
|
|||
|
|
@ -7,6 +7,12 @@ const DEFAULT = {
|
|||
hasBasic: true,
|
||||
has256: true,
|
||||
has16m: true
|
||||
},
|
||||
stderr: {
|
||||
level: 3,
|
||||
hasBasic: true,
|
||||
has256: true,
|
||||
has16m: true
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -105,3 +105,8 @@ test('don\'t emit RGB codes if level is 0', t => {
|
|||
test('supports blackBright color', t => {
|
||||
t.is(chalk.blackBright('foo'), '\u001B[90mfoo\u001B[39m');
|
||||
});
|
||||
|
||||
test('sets correct level for chalk.stderr and respects it', t => {
|
||||
t.is(chalk.stderr.level, 3);
|
||||
t.is(chalk.stderr.red.bold('foo'), '\u001B[31m\u001B[1mfoo\u001B[22m\u001B[39m');
|
||||
});
|
||||
|
|
|
|||
|
|
@ -41,5 +41,5 @@ test('propagate enable/disable changes from child colors', t => {
|
|||
|
||||
test('disable colors if they are not supported', async t => {
|
||||
const {stdout} = await execa.node(path.join(__dirname, '_fixture'));
|
||||
t.is(stdout, 'test');
|
||||
t.is(stdout, 'testout testerr');
|
||||
});
|
||||
|
|
|
|||
|
|
@ -2,10 +2,18 @@ import test from 'ava';
|
|||
|
||||
// Spoof supports-color
|
||||
require('./_supports-color')(__dirname, {
|
||||
level: 0,
|
||||
hasBasic: false,
|
||||
has256: false,
|
||||
has16m: false
|
||||
stdout: {
|
||||
level: 0,
|
||||
hasBasic: false,
|
||||
has256: false,
|
||||
has16m: false
|
||||
},
|
||||
stderr: {
|
||||
level: 0,
|
||||
hasBasic: false,
|
||||
has256: false,
|
||||
has16m: false
|
||||
}
|
||||
});
|
||||
|
||||
const chalk = require('../source');
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue