Skip to content

process.stdout is not detected as writable when redirecting output to a file #5

@catdad

Description

@catdad

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions