File tree 3 files changed +31
-0
lines changed
3 files changed +31
-0
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 @@ -349,9 +349,18 @@ function userInfo(options) {
349
349
return user ;
350
350
}
351
351
352
+ /**
353
+ * @returns {'\\.\nul' | '/dev/nul' }
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 @@ -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 ) ;
You can’t perform that action at this time.
0 commit comments