add support for chalk/stderr (closes #301)

This commit is contained in:
Josh Junon 2019-07-12 19:19:53 +02:00
parent c25c32a25f
commit ba3274ad0c
6 changed files with 264 additions and 225 deletions

View file

@ -7,6 +7,12 @@ const DEFAULT = {
hasBasic: true,
has256: true,
has16m: true
},
stderr: {
level: 2,
hasBasic: true,
has256: true,
has16m: false
}
};

19
test/stderr.js Normal file
View file

@ -0,0 +1,19 @@
import test from 'ava';
// Spoof supports-color
require('./_supports-color')(__dirname);
const chalk = require('../source');
const chalkStderr = require('../stderr');
test('import chalk/stderr with supports-color information for fd2', t => {
t.is(chalk.level, 3);
t.is(chalkStderr.level, 2);
t.is(chalkStderr.red('foo'), '\u001B[31mfoo\u001B[39m');
});
test('create isolated instance of stderr chalk', t => {
const instance = new chalkStderr.Instance();
t.is(instance.level, 2);
t.is(instance.red('foo'), '\u001B[31mfoo\u001B[39m');
});