From cd6f2560d0b53f87e0c238d8099df78feb24181d Mon Sep 17 00:00:00 2001 From: Colin Rotherham Date: Wed, 23 Nov 2022 14:47:46 +0000 Subject: [PATCH] Ensure npm scripts (via Gulp) emit errors Whilst we suppress non-zero exit codes for `gulp dev` we should still exit if anything writes to `stderr` --- tasks/run.mjs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/tasks/run.mjs b/tasks/run.mjs index a0a3537f5b..0a6f9e4f09 100644 --- a/tasks/run.mjs +++ b/tasks/run.mjs @@ -14,8 +14,13 @@ export async function npmScript (name, args = []) { return new Promise((resolve, reject) => { const script = spawn(command, ['run', name, '--silent', ...args]) + // Send output to console script.stdout.on('data', (data) => console.log(data.toString())) - script.stderr.on('data', (data) => console.error(data.toString())) + + // Emit errors to error listener + script.stderr.on('data', (data) => { + script.emit('error', new Error(data.toString())) + }) // Reject on actual script errors to exit `gulp dev` script.on('error', reject)