sindresorhus / hook-std

Hook and modify stdout and stderr
MIT License
54 stars 12 forks source link

Allow to hook into any writable stream #18

Closed pvdlg closed 6 years ago

pvdlg commented 6 years ago

This would add the option streams that would accept an Array of Writable streams. By default if would be:

The library would then do the same usual, but would get the stream to hook into fro m the new option rather than from process.

sindresorhus commented 6 years ago

Seems like a good option to have. What is your use-case?

It is a little bit weird that hookStd.stdout({streams: [process.stderr]}) would be allowed. Should we maybe contain the option to the main hookStd()? Or do you have a use-case I'm not seeing?

pvdlg commented 6 years ago

I guess when using hookStd.stdout and hookStd.stderr the streams option will be ignored.

The use case is to use a transform function to replace sensitive text from the console output. I also want the user to be able to customize the stdout and stderr used by the library and ultimately pass them to signale.

sindresorhus commented 6 years ago

I guess when using hookStd.stdout and hookStd.stderr the streams option will be ignored.

👍

sindresorhus commented 6 years ago

Alright. PR welcome :)

pvdlg commented 6 years ago

Here is the PR: #19