Skip to content

Commit cf7bd05

Browse files
Kayla Washburnsindresorhus
Kayla Washburn
authored andcommitted
Detect 16m color support on Windows >=10.0.14931 (#71)
1 parent 46d2378 commit cf7bd05

File tree

2 files changed

+15
-2
lines changed

2 files changed

+15
-2
lines changed

index.js

+3-2
Original file line numberDiff line numberDiff line change
@@ -50,14 +50,15 @@ function supportsColor(stream) {
5050
// libuv that enables 256 color output on Windows. Anything earlier and it
5151
// won't work. However, here we target Node.js 8 at minimum as it is an LTS
5252
// release, and Node.js 7 is not. Windows 10 build 10586 is the first Windows
53-
// release that supports 256 colors.
53+
// release that supports 256 colors. Windows 10 build 14931 is the first release
54+
// that supports 16m/TrueColor.
5455
const osRelease = os.release().split('.');
5556
if (
5657
Number(process.versions.node.split('.')[0]) >= 8 &&
5758
Number(osRelease[0]) >= 10 &&
5859
Number(osRelease[2]) >= 10586
5960
) {
60-
return 2;
61+
return Number(osRelease[2]) >= 14931 ? 3 : 2;
6162
}
6263

6364
return 1;

test.js

+12
Original file line numberDiff line numberDiff line change
@@ -295,3 +295,15 @@ test('return level 2 if on Windows 10 build 10586 or later and Node version is >
295295
const result = importFresh('.');
296296
t.is(result.stdout.level, 2);
297297
});
298+
299+
test('return level 3 if on Windows 10 build 14931 or later and Node version is >= 8.0.0', t => {
300+
Object.defineProperty(process, 'platform', {
301+
value: 'win32'
302+
});
303+
Object.defineProperty(process.versions, 'node', {
304+
value: '8.0.0'
305+
});
306+
os.release = () => '10.0.14931';
307+
const result = importFresh('.');
308+
t.is(result.stdout.level, 3);
309+
});

0 commit comments

Comments
 (0)