Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 9249603

Browse files
Use 16m colors if possible.
Signed-off-by: Eric Wang <skygragon@gmail.com>
1 parent 05d40ca commit 9249603

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

‎lib/chalk.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ var supportsColor = require('supports-color');
66
const chalk = {
77
enabled: supportsColor.stdout,
88
use256: supportsColor.stdout && supportsColor.stdout.has256,
9+
use16m: supportsColor.stdout && supportsColor.stdout.has16m,
910
themes: new Map(),
1011
theme: {}
1112
};
@@ -30,7 +31,9 @@ chalk.setTheme = function(name) {
3031
};
3132

3233
chalk.sprint = function(s, hex) {
33-
const color = chalk.use256 ? style.color.ansi256.hex(hex) : style.color.ansi.hex(hex);
34+
const color = chalk.use16m ? style.color.ansi16m.hex(hex)
35+
: chalk.use256 ? style.color.ansi256.hex(hex)
36+
: style.color.ansi.hex(hex);
3437
return color + s + style.color.close;
3538
};
3639

@@ -60,7 +63,10 @@ chalk.init = function() {
6063
const v = x[1];
6164
const bgK = bgName(k);
6265

63-
if (chalk.use256) {
66+
if (chalk.use16m) {
67+
theme[k] = style.color.ansi16m.hex(v);
68+
theme[bgK] = style.bgColor.ansi16m.hex(v);
69+
} else if (chalk.use256) {
6470
theme[k] = style.color.ansi256.hex(v);
6571
theme[bgK] = style.bgColor.ansi256.hex(v);
6672
} else {

‎test/test_chalk.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ describe('chalk', function() {
1010
chalk = rewire('../lib/chalk');
1111
chalk.enabled = true;
1212
chalk.use256 = true;
13+
chalk.use16m = false;
1314
});
1415

1516
it('should ok w/ 256 colors', function() {

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /