Skip to content

Commit

Permalink
Catch error events on runner child; console.error all stdin errors
Browse files Browse the repository at this point in the history
  • Loading branch information
e-pavlica committed Mar 7, 2018
1 parent e310ab1 commit bbaebdc
Showing 1 changed file with 6 additions and 9 deletions.
15 changes: 6 additions & 9 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down

0 comments on commit bbaebdc

Please sign in to comment.