Deprecate chalk.constructor() in favor of new chalk.Instance() (#322)

This commit is contained in:
Tom Sherman 2019-03-12 12:53:03 +00:00 committed by Sindre Sorhus
parent 60959e05cf
commit de2f4cd606
11 changed files with 110 additions and 88 deletions

View file

@ -2,12 +2,12 @@
import chalk from '..';
// $ExpectError (Can't have typo in option name)
chalk.constructor({levl: 1});
chalk.constructor({level: 1});
new chalk.Instance({levl: 1});
new chalk.Instance({level: 1});
// $ExpectError (Option must have proper type)
new chalk.constructor({enabled: 'true'});
new chalk.constructor({enabled: true});
new chalk.Instance({enabled: 'true'});
new chalk.Instance({enabled: true});
// $ExpectError (Can't have typo in chalk method)
chalk.rd('foo');
@ -22,8 +22,8 @@ chalk.red.bgBlu.underline('foo');
chalk.red.bgBlue.underline('foo');
// $ExpectError (Level must be 0, 1, 2, or 3)
const badCtx = chalk.constructor({level: 4});
const ctx = chalk.constructor({level: 3});
const badCtx = chalk.Instance({level: 4});
const ctx = chalk.Instance({level: 3});
// $ExpectError (Can't have typo in method name)
ctx.gry('foo');
@ -41,7 +41,7 @@ chalk.enabled = true;
chalk.level = 10;
chalk.level = 1;
const chalkInstance = new chalk.constructor();
const chalkInstance = new chalk.Instance();
// $ExpectError (Can't have typo in method name)
chalkInstance.blu('foo');