From bbaebdcbd49deb5a80e012b5006c2221c0f47e2f Mon Sep 17 00:00:00 2001 From: Evan Pavlica Date: Wed, 7 Mar 2018 14:27:28 -0800 Subject: [PATCH] Catch error events on runner child; console.error all stdin errors --- index.js | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/index.js b/index.js index 3a9c0a5..11f74b9 100644 --- a/index.js +++ b/index.js @@ -109,16 +109,13 @@ function transformSource (runner, config, source, map, callback) { } }) + child.on('error', callback) + child.stdin.on('error', function (error) { - // When the `runner` command is not found, stdin will not be open. - // Attemping to write then causes an EPIPE error. Ignore this because the - // `exec` callback gives a more meaningful error that we show to the user. - if (error.code !== 'EPIPE') { - console.error( - 'rails-erb-loader encountered an unexpected error while writing to stdin: "' + - error.message + '". Please report this to the maintainers.' - ) - } + console.error( + 'rails-erb-loader encountered an unexpected error while writing to stdin: "' + + error.message + '". Please report this to the maintainers.' + ) }) child.stdin.write(source) child.stdin.end()