Demonstrate crash when using Truecolor methods and color is unsupported (#174)
This commit is contained in:
parent
23092eefd2
commit
5cdd9eddf8
3 changed files with 13 additions and 0 deletions
4
fixture.js
Normal file
4
fixture.js
Normal file
|
|
@ -0,0 +1,4 @@
|
||||||
|
'use strict';
|
||||||
|
const chalk = require('.');
|
||||||
|
|
||||||
|
console.log(chalk.hex('#ff6159')('test'));
|
||||||
|
|
@ -46,6 +46,7 @@
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"coveralls": "^2.11.2",
|
"coveralls": "^2.11.2",
|
||||||
|
"execa": "^0.7.0",
|
||||||
"import-fresh": "^2.0.0",
|
"import-fresh": "^2.0.0",
|
||||||
"matcha": "^0.7.0",
|
"matcha": "^0.7.0",
|
||||||
"mocha": "*",
|
"mocha": "*",
|
||||||
|
|
|
||||||
8
test.js
8
test.js
|
|
@ -2,6 +2,7 @@
|
||||||
const assert = require('assert');
|
const assert = require('assert');
|
||||||
const importFresh = require('import-fresh');
|
const importFresh = require('import-fresh');
|
||||||
const resolveFrom = require('resolve-from');
|
const resolveFrom = require('resolve-from');
|
||||||
|
const execa = require('execa');
|
||||||
|
|
||||||
// Spoof supports-color
|
// Spoof supports-color
|
||||||
require.cache[resolveFrom(__dirname, 'supports-color')] = {
|
require.cache[resolveFrom(__dirname, 'supports-color')] = {
|
||||||
|
|
@ -202,6 +203,13 @@ describe('chalk.level', () => {
|
||||||
assert.equal(chalk.level, 1);
|
assert.equal(chalk.level, 1);
|
||||||
chalk.level = oldLevel;
|
chalk.level = oldLevel;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should disable colors if they are not supported', () => {
|
||||||
|
return execa('node', ['fixture'])
|
||||||
|
.then(result => {
|
||||||
|
assert.equal(result.stdout, 'test');
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('chalk.enabled', () => {
|
describe('chalk.enabled', () => {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue