File tree Expand file tree Collapse file tree 6 files changed +31
-20
lines changed Expand file tree Collapse file tree 6 files changed +31
-20
lines changed Original file line number Diff line number Diff line change @@ -122,6 +122,18 @@ The properties included on each object include:
122
122
` nice ` values are POSIX-only. On Windows, the ` nice ` values of all processors
123
123
are always 0.
124
124
125
+ ## ` os.devnull() `
126
+ <!-- YAML
127
+ added: REPLACEME
128
+ -->
129
+
130
+ * Returns: {string}
131
+
132
+ Returns the platform-specific file path of the null device:
133
+
134
+ * ` \\.\nul ` on Windows
135
+ * ` /dev/null ` on POSIX
136
+
125
137
## ` os.endianness() `
126
138
<!-- YAML
127
139
added: v0.9.4
Original file line number Diff line number Diff line change @@ -135,18 +135,6 @@ process.env.PATH.split(path.delimiter);
135
135
// Returns ['C:\\Windows\\system32', 'C:\\Windows', 'C:\\Program Files\\node\\']
136
136
```
137
137
138
- ## ` path.devnull `
139
- <!-- YAML
140
- added: REPLACEME
141
- -->
142
-
143
- * {string}
144
-
145
- Provides the platform-specific file path of the null device:
146
-
147
- * ` \\.\nul ` on Windows
148
- * ` /dev/null ` on POSIX
149
-
150
138
## ` path.dirname(path) `
151
139
<!-- YAML
152
140
added: v0.1.16
Original file line number Diff line number Diff line change @@ -349,9 +349,18 @@ function userInfo(options) {
349
349
return user ;
350
350
}
351
351
352
+ /**
353
+ * @returns {string }
354
+ */
355
+ function devnull ( ) {
356
+ return isWindows ? '\\\\.\\nul' : '/dev/null' ;
357
+ }
358
+ devnull [ SymbolToPrimitive ] = ( ) => devnull ( ) ;
359
+
352
360
module . exports = {
353
361
arch,
354
362
cpus,
363
+ devnull,
355
364
endianness,
356
365
freemem : getFreeMem ,
357
366
getPriority,
Original file line number Diff line number Diff line change @@ -1065,7 +1065,6 @@ const win32 = {
1065
1065
return ret ;
1066
1066
} ,
1067
1067
1068
- devnull : '\\\\.\\nul' ,
1069
1068
sep : '\\' ,
1070
1069
delimiter : ';' ,
1071
1070
win32 : null ,
@@ -1532,7 +1531,6 @@ const posix = {
1532
1531
return ret ;
1533
1532
} ,
1534
1533
1535
- devnull : '/dev/null' ,
1536
1534
sep : '/' ,
1537
1535
delimiter : ':' ,
1538
1536
win32 : null ,
Original file line number Diff line number Diff line change @@ -259,3 +259,13 @@ if (!common.isIBMi) {
259
259
260
260
is . number ( + os . freemem , 'freemem' ) ;
261
261
is . number ( os . freemem ( ) , 'freemem' ) ;
262
+
263
+ const devnull = os . devnull ( ) ;
264
+
265
+ if ( common . isWindows ) {
266
+ assert . strictEqual ( devnull , '\\\\.\\nul' ) ;
267
+ } else {
268
+ assert . strictEqual ( devnull , '/dev/null' ) ;
269
+ }
270
+
271
+ assert . strictEqual ( `${ os . devnull } ` , devnull ) ;
Original file line number Diff line number Diff line change @@ -67,12 +67,6 @@ assert.strictEqual(path.win32.delimiter, ';');
67
67
// posix
68
68
assert . strictEqual ( path . posix . delimiter , ':' ) ;
69
69
70
- // path.devnull tests
71
- // windows
72
- assert . strictEqual ( path . win32 . devnull , '\\\\.\\nul' ) ;
73
- // posix
74
- assert . strictEqual ( path . posix . devnull , '/dev/null' ) ;
75
-
76
70
if ( common . isWindows )
77
71
assert . strictEqual ( path , path . win32 ) ;
78
72
else
You can’t perform that action at this time.
0 commit comments