Sample code:
var isStream = require('is-stream');
console.log('is writable:', isStream.writable(process.stdout));
I have so far only tested this on Windows, here's the output of that test:
C:\Users\Kiril\Desktop\repro>node -v
v4.4.4
C:\Users\Kiril\Desktop\repro>type repro.js
var isStream = require('is-stream');
console.log('is writable:', isStream.writable(process.stdout));
C:\Users\Kiril\Desktop\repro>node repro.js
is writable: true
C:\Users\Kiril\Desktop\repro>node repro.js > file.log
C:\Users\Kiril\Desktop\repro>type file.log
is writable: false
C:\Users\Kiril\Desktop\repro>
When running from the command line, everything is fine and it reports as true. However, when I redirect the same command line to a file, it reports as false. When I checked, both _write and _writableState are undefined. But, of course, you can see that writing to stdout still works and redirects to the file, since console.log works just fine.
Sample code:
I have so far only tested this on Windows, here's the output of that test:
When running from the command line, everything is fine and it reports as
true. However, when I redirect the same command line to a file, it reports asfalse. When I checked, both_writeand_writableStateare undefined. But, of course, you can see that writing to stdout still works and redirects to the file, sinceconsole.logworks just fine.