forked from orbit-oss/chalk
fix missing TERM cases
This commit is contained in:
parent
3fca6150e2
commit
caeb7d8dca
2 changed files with 7 additions and 1 deletions
2
index.js
2
index.js
|
|
@ -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'];
|
||||
|
|
|
|||
6
test.js
6
test.js
|
|
@ -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('.');
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue