-
Notifications
You must be signed in to change notification settings - Fork 29.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fs: fix realpath{Sync} on resolving pipes/sockets
PR-URL: #13028 Reviewed-By: Refael Ackermann <refack@gmail.com>
- Loading branch information
Showing
3 changed files
with
59 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
'use strict'; | ||
|
||
const common = require('../common'); | ||
|
||
if (common.isWindows || common.isAix) { | ||
common.skip(`No /dev/stdin on ${process.platform}.`); | ||
return; | ||
} | ||
|
||
const assert = require('assert'); | ||
|
||
const { spawnSync } = require('child_process'); | ||
|
||
for (const code of [ | ||
`require('fs').realpath('/dev/stdin', (err, resolvedPath) => { | ||
if (err) { | ||
process.exit(1); | ||
} | ||
if (resolvedPath) { | ||
process.exit(2); | ||
} | ||
});`, | ||
`try { | ||
if (require('fs').realpathSync('/dev/stdin')) { | ||
process.exit(2); | ||
} | ||
} catch (e) { | ||
process.exit(1); | ||
}` | ||
]) { | ||
assert.strictEqual(spawnSync(process.execPath, ['-e', code], { | ||
stdio: 'pipe' | ||
}).status, 2); | ||
} |