Remove dim style workaround for Windows (#331)

See: https://github.com/chalk/chalk/pull/330/#issuecomment-471977551

The issue seems to have been fixed in newer Windows 10 builds. We're not interested in adding a conditional for older Windows versions as the fix severely complicates the codebase, and it also creates problems for consumers as it makes the output unpredictable.
This commit is contained in:
Sindre Sorhus 2019-03-13 00:24:34 +07:00 committed by GitHub
parent 2ca015c4c5
commit cd5de7a2f6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 72 deletions

View file

@ -1,51 +0,0 @@
import test from 'ava';
import importFresh from 'import-fresh';
import resolveFrom from 'resolve-from';
// Spoof supports-color
require('./_supports-color')(__dirname);
let originalEnv;
let originalPlatform;
test.before(() => {
originalEnv = process.env;
originalPlatform = process.platform;
});
test.after(() => {
process.env = originalEnv;
Object.defineProperty(process, 'platform', {value: originalPlatform});
});
test.beforeEach(() => {
process.env = {};
Object.defineProperty(process, 'platform', {value: 'win32'});
// Since chalk internally modifies `ansiStyles.blue.open`, `ansi-styles` needs
// to be removed from the require cache for `require-uncached` to work
delete require.cache[resolveFrom(__dirname, 'ansi-styles')];
});
test('detect a simple term if TERM isn\'t set', t => {
delete process.env.TERM;
const chalk = importFresh('..');
t.is(chalk.blue('foo'), '\u001B[34mfoo\u001B[39m');
});
test('don\'t apply dimmed styling on gray strings, see https://github.com/chalk/chalk/issues/58', t => {
process.env.TERM = 'dumb';
const chalk = importFresh('..');
t.is(chalk.gray.dim('foo'), '\u001B[90mfoo\u001B[22m\u001B[39m');
});
test('apply dimmed styling on xterm compatible terminals', t => {
process.env.TERM = 'xterm';
const chalk = importFresh('..');
t.is(chalk.gray.dim('foo'), '\u001B[90m\u001B[2mfoo\u001B[22m\u001B[39m');
});
test('apply dimmed styling on strings of other colors', t => {
process.env.TERM = 'dumb';
const chalk = importFresh('..');
t.is(chalk.blue.dim('foo'), '\u001B[34m\u001B[2mfoo\u001B[22m\u001B[39m');
});