execa
execa copied to clipboard
Automatically wait for file streams to open
It might be possible to wait for the open event on file streams (if we can find a way to detect that a stream is in fact a file stream, and that it will indeed eventually open).
See the discussion here
We could detect the follow custom properties attached to it:
path: 'ad',
fd: null,
flags: 'w',
mode: 438,
Maybe we should add isStream.fsWritable() and isStream.fsReadable() methods to is-stream?
I just made is-file-stream. https://github.com/jamestalmage/is-file-stream
Even better. Less bloat for is-stream. The module looks good.
This is a great idea. Makes working with file streams much easier. I will have a look at implementing this.
I think we should also at least try to get this into Node.js core by opening an issue argumenting it's the expected behavior.
Good point. We probably all know how this will end but at least we can try.
At least we can then reference Node.js' unwillingness to good UX. It's always worth trying to improve core Node.js if possible, as it benefits of lot more users, and of course less code for us to maintain.
Totally agree with that.
Basically, they only allow streams that have file descriptors, and under the hood, they convert streams to those file descriptors.
It would have been way less confusing for them not to allow streams, and just provide a findUnderlyingFileDescriptor(stream).
Streams passed to child_process.spawn are handled completely differently than anywhere else in Node-land. Not having the magical "convenience" of this automatic unwrapping would have ultimately been so much less confusing.
Should this be closed in favor for https://github.com/sindresorhus/execa/issues/617?
(Also relevant: https://github.com/sindresorhus/execa/issues/616)
Yup