diff options
author | Ruben Bridgewater <ruben@bridgewater.de> | 2018-05-06 23:10:23 +0200 |
---|---|---|
committer | Ruben Bridgewater <ruben@bridgewater.de> | 2018-05-18 15:25:41 +0200 |
commit | d478e52fe0bc396c8e65baf0861553a0d3de99db (patch) | |
tree | c569cdafa3ff48fb85e77c6e871b082825c86441 /lib/internal/tty.js | |
parent | 2bfba0dd339d1480e1b5caa64f28e330147845b9 (diff) | |
download | android-node-v8-d478e52fe0bc396c8e65baf0861553a0d3de99db.tar.gz android-node-v8-d478e52fe0bc396c8e65baf0861553a0d3de99db.tar.bz2 android-node-v8-d478e52fe0bc396c8e65baf0861553a0d3de99db.zip |
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>
Diffstat (limited to 'lib/internal/tty.js')
-rw-r--r-- | lib/internal/tty.js | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/lib/internal/tty.js b/lib/internal/tty.js index c4edab24fb..1e60909f66 100644 --- a/lib/internal/tty.js +++ b/lib/internal/tty.js @@ -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. |