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

Appearance settings

Commit 28d00a1

Browse filesBrowse files
BridgeARMylesBorins
authored andcommitted
os: lazy loaded
PR-URL: #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>
1 parent 3eb38de commit 28d00a1
Copy full SHA for 28d00a1

File tree

Expand file treeCollapse file tree

3 files changed

+11
-4
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

3 files changed

+11
-4
lines changed
Open diff view settings
Collapse file

‎lib/assert.js‎

Copy file name to clipboardExpand all lines: lib/assert.js
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ const { codes: {
3333
const { AssertionError, errorCache } = require('internal/assert');
3434
const { openSync, closeSync, readSync } = require('fs');
3535
const { inspect, types: { isPromise, isRegExp } } = require('util');
36-
const { EOL } = require('os');
36+
const { EOL } = require('internal/constants');
3737
const { NativeModule } = require('internal/bootstrap/loaders');
3838

3939
// Escape control characters but not \n and \t to keep the line breaks and
Collapse file

‎lib/internal/constants.js‎

Copy file name to clipboardExpand all lines: lib/internal/constants.js
+4Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
'use strict';
22

3+
const isWindows = process.platform === 'win32';
4+
35
module.exports = {
46
// Alphabet chars.
57
CHAR_UPPERCASE_A: 65, /* A */
@@ -45,4 +47,6 @@ module.exports = {
4547
// Digits
4648
CHAR_0: 48, /* 0 */
4749
CHAR_9: 57, /* 9 */
50+
51+
EOL: isWindows ? '\r\n' : '\n'
4852
};
Collapse file

‎lib/internal/tty.js‎

Copy file name to clipboardExpand all lines: lib/internal/tty.js
+6-3Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,7 @@
2222

2323
'use strict';
2424

25-
const { release } = require('os');
26-
27-
const OSRelease = release().split('.');
25+
let OSRelease;
2826

2927
const COLORS_2 = 1;
3028
const COLORS_16 = 4;
@@ -75,6 +73,11 @@ function getColorDepth(env = process.env) {
7573
}
7674

7775
if (process.platform === 'win32') {
76+
// Lazy load for startup performance.
77+
if (OSRelease === undefined) {
78+
const { release } = require('os');
79+
OSRelease = release().split('.');
80+
}
7881
// Windows 10 build 10586 is the first Windows release that supports 256
7982
// colors. Windows 10 build 14931 is the first release that supports
8083
// 16m/TrueColor.

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.