Skip to content

Commit

Permalink
fix missing TERM cases
Browse files Browse the repository at this point in the history
  • Loading branch information
Qix- committed Jun 30, 2017
1 parent 3fca615 commit caeb7d8
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion index.js
Expand Up @@ -5,7 +5,7 @@ const supportsColor = require('supports-color');

const template = require('./templates.js');

const isSimpleWindowsTerm = process.platform === 'win32' && !process.env.TERM.toLowerCase().startsWith('xterm');
const isSimpleWindowsTerm = process.platform === 'win32' && !(process.env.TERM || '').toLowerCase().startsWith('xterm');

// `supportsColor.level` → `ansiStyles.color[name]` mapping
const levelMapping = ['ansi', 'ansi', 'ansi256', 'ansi16m'];
Expand Down
6 changes: 6 additions & 0 deletions test.js
Expand Up @@ -133,6 +133,12 @@ describe('chalk on windows', () => {
delete require.cache[resolveFrom(__dirname, 'ansi-styles')];
});

it('should detect a simple term if TERM isn\'t set', () => {
delete process.env.TERM;
const chalkCtx = importFresh('.');
assert.equal(chalkCtx.blue('foo'), '\u001B[94mfoo\u001B[39m');
});

it('should replace blue foreground color in cmd.exe', () => {
process.env.TERM = 'dumb';
const chalkCtx = importFresh('.');
Expand Down

0 comments on commit caeb7d8

Please sign in to comment.