os: lazy loaded

PR-URL: https://github.com/nodejs/node/pull/20567
Reviewed-By: Gus Caplan <me@gus.host>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com>
This commit is contained in:
Ruben Bridgewater authored and Myles Borins committed 2018-05-22 14:13:28 -04:00
1 parent 3eb38debb4
commit 28d00a18c8
3 files changed
+11 -4

No files matched your search

+1 -1
View File
@@ -33,7 +33,7 @@ const { codes: {
const { AssertionError, errorCache } = require('internal/assert');
const { openSync, closeSync, readSync } = require('fs');
const { inspect, types: { isPromise, isRegExp } } = require('util');
const { EOL } = require('os');
const { EOL } = require('internal/constants');
const { NativeModule } = require('internal/bootstrap/loaders');
// Escape control characters but not \n and \t to keep the line breaks and
+4
View File
@@ -1,5 +1,7 @@
'use strict';
const isWindows = process.platform === 'win32';
module.exports = {
// Alphabet chars.
CHAR_UPPERCASE_A: 65, /* A */
@@ -45,4 +47,6 @@ module.exports = {
// Digits
CHAR_0: 48, /* 0 */
CHAR_9: 57, /* 9 */
EOL: isWindows ? '\r\n' : '\n'
};
+6 -3
View File
@@ -22,9 +22,7 @@
'use strict';
const { release } = require('os');
const OSRelease = release().split('.');
let OSRelease;
const COLORS_2 = 1;
const COLORS_16 = 4;
@@ -75,6 +73,11 @@ function getColorDepth(env = process.env) {
}
if (process.platform === 'win32') {
// Lazy load for startup performance.
if (OSRelease === undefined) {
const { release } = require('os');
OSRelease = release().split('.');
}
// Windows 10 build 10586 is the first Windows release that supports 256
// colors. Windows 10 build 14931 is the first release that supports
// 16m/TrueColor.