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 f6caeb9

Browse filesBrowse files
XadillaXrefack
authored andcommitted
os: make EOL configurable and read only
PR-URL: #14622 Fixes: #14619 Reviewed-By: Vse Mozhet Byt <vsemozhetbyt@gmail.com> Reviewed-By: Timothy Gu <timothygu99@gmail.com> Reviewed-By: Tobias Nießen <tniessen@tnie.de> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Alexey Orlenko <eaglexrlnk@gmail.com> Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Rod Vagg <rod@vagg.org> Reviewed-By: Refael Ackermann <refack@gmail.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
1 parent 3a886ff commit f6caeb9
Copy full SHA for f6caeb9

File tree

Expand file treeCollapse file tree

2 files changed

+40
-5
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

2 files changed

+40
-5
lines changed
Open diff view settings
Collapse file

‎lib/os.js‎

Copy file name to clipboardExpand all lines: lib/os.js
+13-5Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,6 @@ function networkInterfaces() {
140140
module.exports = exports = {
141141
arch,
142142
cpus,
143-
EOL: isWindows ? '\r\n' : '\n',
144143
endianness,
145144
freemem: getFreeMem,
146145
homedir: getHomeDirectory,
@@ -162,8 +161,17 @@ module.exports = exports = {
162161
tmpDir: deprecate(tmpdir, tmpDirDeprecationMsg, 'DEP0022')
163162
};
164163

165-
Object.defineProperty(module.exports, 'constants', {
166-
configurable: false,
167-
enumerable: true,
168-
value: constants
164+
Object.defineProperties(module.exports, {
165+
constants: {
166+
configurable: false,
167+
enumerable: true,
168+
value: constants
169+
},
170+
171+
EOL: {
172+
configurable: true,
173+
enumerable: true,
174+
writable: false,
175+
value: isWindows ? '\r\n' : '\n'
176+
}
169177
});
Collapse file

‎test/parallel/test-os-eol.js‎

Copy file name to clipboard
+27Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
'use strict';
2+
3+
const common = require('../common');
4+
const assert = require('assert');
5+
const os = require('os');
6+
7+
const eol = common.isWindows ? '\r\n' : '\n';
8+
9+
assert.strictEqual(os.EOL, eol);
10+
11+
common.expectsError(function() {
12+
os.EOL = 123;
13+
}, {
14+
type: TypeError,
15+
message: /^Cannot assign to read only property 'EOL' of object '#<Object>'$/
16+
});
17+
18+
const foo = 'foo';
19+
Object.defineProperties(os, {
20+
EOL: {
21+
configurable: true,
22+
enumerable: true,
23+
writable: false,
24+
value: foo
25+
}
26+
});
27+
assert.strictEqual(os.EOL, foo);

0 commit comments

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