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>
pull/20567/merge
Ruben Bridgewater 2018-05-06 23:10:23 +02:00
parent 2bfba0dd33
commit d478e52fe0
No known key found for this signature in database
GPG Key ID: F07496B3EB3C1762
3 changed files with 11 additions and 4 deletions

View File

@ -34,7 +34,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

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'
};

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.