force blue color to be use bright blue on Windows - fixes #36

as the normal blue color is illegible
This commit is contained in:
Sindre Sorhus 2014-12-05 16:11:13 +07:00
parent 0b1c65dfd3
commit fc6a9b27dc
3 changed files with 15 additions and 10 deletions

View file

@ -7,6 +7,11 @@ var supportsColor = require('supports-color');
var defineProps = Object.defineProperties; var defineProps = Object.defineProperties;
var chalk = module.exports; var chalk = module.exports;
// use bright blue on Windows as the normal blue color is illegible
if (process.platform === 'win32') {
ansiStyles.blue.open = '\u001b[94m';
}
function build(_styles) { function build(_styles) {
var builder = function builder() { var builder = function builder() {
return applyStyle.apply(builder, arguments); return applyStyle.apply(builder, arguments);

View file

@ -155,7 +155,7 @@ if (!chalk.supportsColor) {
- `red` - `red`
- `green` - `green`
- `yellow` - `yellow`
- `blue` - `blue` *(on Windows the bright version is used as normal blue is illegible)*
- `magenta` - `magenta`
- `cyan` - `cyan`
- `white` - `white`

18
test.js
View file

@ -23,8 +23,8 @@ describe('chalk', function () {
it('should support nesting styles of the same type (color, underline, bg)', function () { it('should support nesting styles of the same type (color, underline, bg)', function () {
assert.equal( assert.equal(
chalk.red('a' + chalk.blue('b' + chalk.green('c') + 'b') + 'c'), chalk.red('a' + chalk.yellow('b' + chalk.green('c') + 'b') + 'c'),
'\u001b[31ma\u001b[34mb\u001b[32mc\u001b[34mb\u001b[31mc\u001b[39m' '\u001b[31ma\u001b[33mb\u001b[32mc\u001b[33mb\u001b[31mc\u001b[39m'
); );
}); });
@ -34,13 +34,13 @@ describe('chalk', function () {
it('should be able to cache multiple styles', function() { it('should be able to cache multiple styles', function() {
var red = chalk.red; var red = chalk.red;
var blue = chalk.blue; var green = chalk.green;
var redBold = red.bold; var redBold = red.bold;
var blueBold = blue.bold; var greenBold = green.bold;
assert.notEqual(red('foo'), blue('foo')); assert.notEqual(red('foo'), green('foo'));
assert.notEqual(redBold('bar'), blueBold('bar')); assert.notEqual(redBold('bar'), greenBold('bar'));
assert.notEqual(blue('baz'), blueBold('baz')); assert.notEqual(green('baz'), greenBold('baz'));
}); });
it('should alias gray to grey', function () { it('should alias gray to grey', function () {
@ -76,8 +76,8 @@ describe('chalk.styles', function () {
describe('chalk.hasColor()', function () { describe('chalk.hasColor()', function () {
it('should detect whether a string has color', function () { it('should detect whether a string has color', function () {
assert(chalk.hasColor(chalk.blue('foo'))); assert(chalk.hasColor(chalk.green('foo')));
assert(!chalk.hasColor(chalk.stripColor(chalk.blue('foo')))); assert(!chalk.hasColor(chalk.stripColor(chalk.green('foo'))));
}); });
}); });