File tree Expand file tree Collapse file tree 1 file changed +10
-8
lines changed
Expand file tree Collapse file tree 1 file changed +10
-8
lines changed Original file line number Diff line number Diff line change @@ -8,19 +8,21 @@ const fstat = promisify(fstat_);
88export async function readStdin ( stdinStream : typeof process . stdin = process . stdin ) {
99 // The best showcase of what this does: https://stackoverflow.com/a/59024214
1010 const pipedIn = await fstat ( 0 )
11- . then ( ( stat ) => stat . isFIFO ( ) )
11+ . then ( ( stat ) => {
12+ // isFIFO -> `node a | node b`
13+ // isFile -> `node a < file`
14+ return stat . isFIFO ( ) || stat . isFile ( ) ;
15+ } )
1216 . catch ( ( ) => false ) ;
1317
14- // The isTTY params says if TTY is connected to the process, if so the stdout is
15- // synchronous and the stdout steam is empty.
16- // See https://nodejs.org/docs/latest-v12.x/api/process.html#process_a_note_on_process_i_o
17- if ( stdinStream . isTTY || ( stdinStream . readableEnded && ! pipedIn ) ) {
18+ // The isTTY params will be true if there is no piping into stdin
19+ // pipedIn is set if someone either runs `node a | node b`, or `node a < file`
20+ // if that is the case, isTTY will be undefined (???)
21+ // readableEnded is a catch all for when the stream is closed
22+ if ( stdinStream . isTTY || ( ! pipedIn && ( stdinStream . isTTY === undefined || stdinStream . readableEnded ) ) ) {
1823 return ;
1924 }
2025
21- // This is required for some reason when piping from a previous oclif run
22- stdinStream . resume ( ) ;
23-
2426 const bufferChunks : Buffer [ ] = [ ] ;
2527
2628 stdinStream . on ( 'data' , ( chunk ) => {
You can’t perform that action at this time.
0 commit comments