Add back apply, bind, and call from Function
This commit is contained in:
parent
797461ee32
commit
e3d0e1a16b
2 changed files with 16 additions and 0 deletions
|
|
@ -41,6 +41,10 @@ const chalkFactory = options => {
|
||||||
Object.setPrototypeOf(chalk, Chalk.prototype);
|
Object.setPrototypeOf(chalk, Chalk.prototype);
|
||||||
Object.setPrototypeOf(chalk.template, chalk);
|
Object.setPrototypeOf(chalk.template, chalk);
|
||||||
|
|
||||||
|
chalk.template.apply = Function.prototype.apply;
|
||||||
|
chalk.template.bind = Function.prototype.bind;
|
||||||
|
chalk.template.call = Function.prototype.call;
|
||||||
|
|
||||||
chalk.template.constructor = () => {
|
chalk.template.constructor = () => {
|
||||||
throw new Error('`chalk.constructor()` is deprecated. Use `new chalk.Instance()` instead.');
|
throw new Error('`chalk.constructor()` is deprecated. Use `new chalk.Instance()` instead.');
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -110,3 +110,15 @@ test('sets correct level for chalk.stderr and respects it', t => {
|
||||||
t.is(chalk.stderr.level, 3);
|
t.is(chalk.stderr.level, 3);
|
||||||
t.is(chalk.stderr.red.bold('foo'), '\u001B[31m\u001B[1mfoo\u001B[22m\u001B[39m');
|
t.is(chalk.stderr.red.bold('foo'), '\u001B[31m\u001B[1mfoo\u001B[22m\u001B[39m');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('keeps .apply from Function', t => {
|
||||||
|
t.is(chalk.apply(chalk, ['foo']), 'foo');
|
||||||
|
});
|
||||||
|
|
||||||
|
test('keeps .bind from Function', t => {
|
||||||
|
t.is(chalk.bind(chalk, 'foo')(), 'foo');
|
||||||
|
});
|
||||||
|
|
||||||
|
test('keeps .call from Function', t => {
|
||||||
|
t.is(chalk.call(chalk, 'foo'), 'foo');
|
||||||
|
});
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue