Skip to content
Permalink
Browse files

Demonstrate crash when using Truecolor methods and color is unsupport…

…ed (#174)
  • Loading branch information...
vadimdemedes authored and sindresorhus committed Jul 21, 2017
1 parent 23092ee commit 5cdd9eddf8d1e53c03b3bb122004786fb90706bf
Showing with 13 additions and 0 deletions.
  1. +4 −0 fixture.js
  2. +1 −0 package.json
  3. +8 −0 test.js
@@ -0,0 +1,4 @@
'use strict';
const chalk = require('.');

console.log(chalk.hex('#ff6159')('test'));
@@ -46,6 +46,7 @@
},
"devDependencies": {
"coveralls": "^2.11.2",
"execa": "^0.7.0",
"import-fresh": "^2.0.0",
"matcha": "^0.7.0",
"mocha": "*",
@@ -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')] = {
@@ -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', () => {

0 comments on commit 5cdd9ed

Please sign in to comment.
You can’t perform that action at this time.