Skip to content

Commit

Permalink
Merge pull request #3078 from alphagov/gulp-errors-npm-run
Browse files Browse the repository at this point in the history
Allow nodemon to continue after `npm run serve` errors
  • Loading branch information
colinrotherham committed Dec 7, 2022
2 parents 1422239 + 78a7f0f commit 605faea
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion tasks/run.mjs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import { spawn } from 'child_process'

import { isDev } from './task-arguments.mjs'

/**
* Spawns Node.js child process for npm script
* rather than using Gulp
Expand All @@ -19,7 +21,12 @@ export async function npmScript (name, args = []) {

// Emit errors to error listener
script.stderr.on('data', (data) => {
script.emit('error', new Error(data.toString()))
const error = new Error(data.toString())

// Log errors (without rejection) in development
return isDev
? console.error(error)
: script.emit('error', error)
})

// Reject on actual script errors to exit `gulp dev`
Expand Down

0 comments on commit 605faea

Please sign in to comment.