Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Demonstrate crash when using Truecolor methods and color is unsupport…
…ed (#174)
  • Loading branch information
Vadim Demedes authored and sindresorhus committed Jul 21, 2017
1 parent 23092ee commit 5cdd9ed
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 0 deletions.
4 changes: 4 additions & 0 deletions fixture.js
@@ -0,0 +1,4 @@
'use strict';
const chalk = require('.');

console.log(chalk.hex('#ff6159')('test'));
1 change: 1 addition & 0 deletions package.json
Expand Up @@ -46,6 +46,7 @@
},
"devDependencies": {
"coveralls": "^2.11.2",
"execa": "^0.7.0",
"import-fresh": "^2.0.0",
"matcha": "^0.7.0",
"mocha": "*",
Expand Down
8 changes: 8 additions & 0 deletions test.js
Expand Up @@ -2,6 +2,7 @@
const assert = require('assert');
const importFresh = require('import-fresh');
const resolveFrom = require('resolve-from');
const execa = require('execa');

// Spoof supports-color
require.cache[resolveFrom(__dirname, 'supports-color')] = {
Expand Down Expand Up @@ -202,6 +203,13 @@ describe('chalk.level', () => {
assert.equal(chalk.level, 1);
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', () => {
Expand Down

0 comments on commit 5cdd9ed

Please sign in to comment.