From b066b6e91d69cc7da4e0be648f2349c6d47038be Mon Sep 17 00:00:00 2001 From: Colin Rotherham Date: Mon, 10 Sep 2018 15:40:52 +0100 Subject: [PATCH] Add npm install reminder on crash --- CHANGELOG.md | 6 ++++++ gulp/nodemon.js | 30 +++++++++++++++++++++--------- 2 files changed, 27 insertions(+), 9 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0336547782..97d7ded892 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.0.0 Breaking changes: 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) })