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:
122122` nice ` values are POSIX-only. On Windows, the ` nice ` values of all processors
123123are always 0.
124124
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+
125137## ` os.endianness() `
126138<!-- YAML
127139added: v0.9.4
Original file line number Diff line number Diff line change @@ -135,18 +135,6 @@ process.env.PATH.split(path.delimiter);
135135// Returns ['C:\\Windows\\system32', 'C:\\Windows', 'C:\\Program Files\\node\\']
136136```
137137
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-
150138## ` path.dirname(path) `
151139<!-- YAML
152140added: v0.1.16
Original file line number Diff line number Diff line change @@ -349,9 +349,18 @@ function userInfo(options) {
349349 return user ;
350350}
351351
352+ /**
353+ * @returns {string }
354+ */
355+ function devnull ( ) {
356+ return isWindows ? '\\\\.\\nul' : '/dev/null' ;
357+ }
358+ devnull [ SymbolToPrimitive ] = ( ) => devnull ( ) ;
359+
352360module . exports = {
353361 arch,
354362 cpus,
363+ devnull,
355364 endianness,
356365 freemem : getFreeMem ,
357366 getPriority,
Original file line number Diff line number Diff line change @@ -1065,7 +1065,6 @@ const win32 = {
10651065 return ret ;
10661066 } ,
10671067
1068- devnull : '\\\\.\\nul' ,
10691068 sep : '\\' ,
10701069 delimiter : ';' ,
10711070 win32 : null ,
@@ -1532,7 +1531,6 @@ const posix = {
15321531 return ret ;
15331532 } ,
15341533
1535- devnull : '/dev/null' ,
15361534 sep : '/' ,
15371535 delimiter : ':' ,
15381536 win32 : null ,
Original file line number Diff line number Diff line change @@ -259,3 +259,13 @@ if (!common.isIBMi) {
259259
260260is . number ( + os . freemem , 'freemem' ) ;
261261is . 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, ';');
6767// posix
6868assert . strictEqual ( path . posix . delimiter , ':' ) ;
6969
70- // path.devnull tests
71- // windows
72- assert . strictEqual ( path . win32 . devnull , '\\\\.\\nul' ) ;
73- // posix
74- assert . strictEqual ( path . posix . devnull , '/dev/null' ) ;
75-
7670if ( common . isWindows )
7771 assert . strictEqual ( path , path . win32 ) ;
7872else
You can’t perform that action at this time.
0 commit comments