diff --git a/CHANGELOG.md b/CHANGELOG.md index f53bdea77a..2bfee3c2b2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,9 @@ +# Unreleased + +New features: + +- [Add npm install reminder when prototype crashes](https://github.com/alphagov/govuk-prototype-kit/pull/598) + # 8.1.0 New features: diff --git a/gulp/nodemon.js b/gulp/nodemon.js index 2f08392437..d011b42c82 100644 --- a/gulp/nodemon.js +++ b/gulp/nodemon.js @@ -8,23 +8,35 @@ const fs = require('fs') const path = require('path') const gulp = require('gulp') +const gutil = require('gulp-util') const nodemon = require('gulp-nodemon') const config = require('./config.json') +// Warn about npm install on crash +const onCrash = () => { + gutil.log(gutil.colors.cyan('[nodemon] For missing modules try running `npm install`')) +} + +// Remove .port.tmp if it exists +const onQuit = () => { + try { + fs.unlinkSync(path.join(__dirname, '/../.port.tmp')) + } catch (e) {} + + process.exit(0) +} + gulp.task('server', function () { nodemon({ watch: ['.env', '**/*.js', '**/*.json'], script: 'server.js', - ignore: [config.paths.public + '*', + ignore: [ + config.paths.public + '*', config.paths.assets + '*', - config.paths.nodeModules + '*'] - }).on('quit', function () { - // remove .port.tmp if it exists - try { - fs.unlinkSync(path.join(__dirname, '/../.port.tmp')) - } catch (e) {} - - process.exit(0) + config.paths.nodeModules + '*' + ] }) + .on('crash', onCrash) + .on('quit', onQuit) })