Closed
Description
- Version: v10.6.0
- Platform:
Linux localhost 3.10.0-862.6.3.el7.x86_64 #1 SMP Tue Jun 26 16:32:21 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux
andDarwin localhost 17.7.0 Darwin Kernel Version 17.7.0: Thu Jun 21 22:53:14 PDT 2018; root:xnu-4570.71.2~1/RELEASE_X86_64 x86_64
- Subsystem: fs.promises
The <(cmd)
process substitution shell feature runs a command and passes its output to another command as a pipe named /dev/fd/NNN
.
fs.promises.readFile
returns a 0-length buffer when reading from that path.
$ cat read-fd
console.log(process.argv[2])
const fs = require('fs');
if (process.argv[3] === 'callback') {
fs.readFile(process.argv[2], (err, data) => {
console.log(`err=${err} data=${data} datalen=${data.length}`);
});
} else {
fs.promises.readFile(process.argv[2]).then(d => console.log(d.length));
}
$ echo -n hello there > foo
$ node read-fd foo callback
foo
err=null data=hello there datalen=11
$ node read-fd foo
foo
(node:92585) ExperimentalWarning: The fs.promises API is experimental
11
$ node read-fd <(echo -n hello there) callback
/dev/fd/63
err=null data=hello there datalen=11
$ node read-fd <(echo -n hello there)
/dev/fd/63
(node:92592) ExperimentalWarning: The fs.promises API is experimental
0
Activity