style(stderr): use chalkStderr instead of cherr
This commit is contained in:
parent
5fd274a799
commit
f29eaaec43
4 changed files with 23 additions and 23 deletions
|
|
@ -1,27 +1,27 @@
|
|||
import {expectType} from 'tsd-check';
|
||||
import cherr, {Level, Chalk, ColorSupport} from './stderr';
|
||||
import chalkStderr, {Level, Chalk, ColorSupport} from './stderr';
|
||||
|
||||
// - Helpers -
|
||||
type colorReturn = Chalk & {supportsColor: ColorSupport};
|
||||
|
||||
// - supportsColor -
|
||||
expectType<boolean>(cherr.supportsColor.hasBasic);
|
||||
expectType<boolean>(cherr.supportsColor.has256);
|
||||
expectType<boolean>(cherr.supportsColor.has16m);
|
||||
expectType<boolean>(chalkStderr.supportsColor.hasBasic);
|
||||
expectType<boolean>(chalkStderr.supportsColor.has256);
|
||||
expectType<boolean>(chalkStderr.supportsColor.has16m);
|
||||
|
||||
// - Chalk -
|
||||
// -- Constructor --
|
||||
expectType<Chalk>(new cherr.constructor({level: 1}));
|
||||
expectType<Chalk>(new chalkStderr.constructor({level: 1}));
|
||||
|
||||
// -- Properties --
|
||||
expectType<boolean>(cherr.enabled);
|
||||
expectType<Level>(cherr.level);
|
||||
expectType<boolean>(chalkStderr.enabled);
|
||||
expectType<Level>(chalkStderr.level);
|
||||
|
||||
// -- Template literal --
|
||||
expectType<string>(cherr``);
|
||||
expectType<string>(chalkStderr``);
|
||||
|
||||
// -- Color methods --
|
||||
expectType<colorReturn>(cherr.hex('#DEADED'));
|
||||
expectType<colorReturn>(chalkStderr.hex('#DEADED'));
|
||||
|
||||
// -- Complex --
|
||||
expectType<string>(cherr.underline.red.bgGreen('foo'));
|
||||
expectType<string>(chalkStderr.underline.red.bgGreen('foo'));
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
'use strict';
|
||||
const chalk = require('..');
|
||||
const cherr = require('../stderr');
|
||||
const chalkStderr = require('../stderr');
|
||||
|
||||
console.log(chalk.hex('#ff6159')('test'));
|
||||
console.error(cherr.hex('#ffe861')('test stderr'));
|
||||
console.error(chalkStderr.hex('#ffe861')('test stderr'));
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
// @flow
|
||||
import chalk from '..';
|
||||
import cherr from '../stderr';
|
||||
import chalkStderr from '../stderr';
|
||||
|
||||
// $ExpectError (Can't have typo in option name)
|
||||
chalk.constructor({levl: 1});
|
||||
|
|
@ -15,8 +15,8 @@ chalk.underline(null);
|
|||
chalk.underline('foo');
|
||||
|
||||
// $ExpectError (Can't pass in null)
|
||||
cherr.underline(null);
|
||||
cherr.underline('foo');
|
||||
chalkStderr.underline(null);
|
||||
chalkStderr.underline('foo');
|
||||
|
||||
// $ExpectError (Can't have typo in chalk method)
|
||||
chalk.rd('foo');
|
||||
|
|
|
|||
|
|
@ -5,21 +5,21 @@ import execa from 'execa';
|
|||
// Spoof supports-color
|
||||
require('./_supports-color')(__dirname);
|
||||
|
||||
const cherr = require('../stderr');
|
||||
const chalkStderr = require('../stderr');
|
||||
|
||||
test('stderr don\'t output colors when manually disabled', t => {
|
||||
cherr.enabled = false;
|
||||
t.is(cherr.red('foo'), 'foo');
|
||||
cherr.enabled = true;
|
||||
chalkStderr.enabled = false;
|
||||
t.is(chalkStderr.red('foo'), 'foo');
|
||||
chalkStderr.enabled = true;
|
||||
});
|
||||
|
||||
test('stderr enable/disable colors based on overall chalk enabled property, not individual instances', t => {
|
||||
cherr.enabled = false;
|
||||
const {red} = cherr;
|
||||
chalkStderr.enabled = false;
|
||||
const {red} = chalkStderr;
|
||||
t.false(red.enabled);
|
||||
cherr.enabled = true;
|
||||
chalkStderr.enabled = true;
|
||||
t.true(red.enabled);
|
||||
cherr.enabled = true;
|
||||
chalkStderr.enabled = true;
|
||||
});
|
||||
|
||||
test('disable colors if they are not supported', async t => {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue