Skip to content

Commit

Permalink
path: add path.devnull
Browse files Browse the repository at this point in the history
`path.devnull` provides the platform-specific file path of the null
device.
  • Loading branch information
lpinca committed May 6, 2021
1 parent aed17e9 commit ad1961d
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 0 deletions.
12 changes: 12 additions & 0 deletions doc/api/path.md
Expand Up @@ -135,6 +135,18 @@ process.env.PATH.split(path.delimiter);
// Returns ['C:\\Windows\\system32', 'C:\\Windows', 'C:\\Program Files\\node\\']
```

## `path.devnull`
<!-- YAML
added: REPLACEME
-->

* {string}

Provides the platform-specific file path of the null device:

* `\\.\nul` on Windows
* `/dev/null` on POSIX

## `path.dirname(path)`
<!-- YAML
added: v0.1.16
Expand Down
2 changes: 2 additions & 0 deletions lib/path.js
Expand Up @@ -1065,6 +1065,7 @@ const win32 = {
return ret;
},

devnull: '\\\\.\\nul',
sep: '\\',
delimiter: ';',
win32: null,
Expand Down Expand Up @@ -1531,6 +1532,7 @@ const posix = {
return ret;
},

devnull: '/dev/null',
sep: '/',
delimiter: ':',
win32: null,
Expand Down
6 changes: 6 additions & 0 deletions test/parallel/test-path.js
Expand Up @@ -67,6 +67,12 @@ assert.strictEqual(path.win32.delimiter, ';');
// posix
assert.strictEqual(path.posix.delimiter, ':');

// path.devnull tests
// windows
assert.strictEqual(path.win32.devnull, '\\\\.\\nul');
// posix
assert.strictEqual(path.posix.devnull, '/dev/null');

if (common.isWindows)
assert.strictEqual(path, path.win32);
else
Expand Down

0 comments on commit ad1961d

Please sign in to comment.