errorify icon indicating copy to clipboard operation
errorify copied to clipboard

Create `onError` hook for custom logging and notifications

Open dwaltrip opened this issue 8 years ago • 0 comments

Hey! Thanks for your project. I've found it to be useful.

I wanted to be able to modify the stderr messages that are printed to the terminal when a build has issues, and also allow for other useful things like sending a native OS notification to the developer (using node-notifier for example). This led me to create a hook called onError. It is similar to the replacer option.

If the user passes a function with the onError option, it will be called instead of the currently existing default logger. The function receives the err object as its only parameter.

I thought this feature might be useful as part of the main project. Let me know what you think. I've added tests and updated the README, trying to stay consistent with the rest of the project. For the tests, I used std-mocks to capture stderr output and assert against it.

I'll be happy to make any adjustments if needed.

Cheers, Daniel

dwaltrip avatar Jul 28 '16 21:07 dwaltrip