Skip to content

Commit

Permalink
Add npm install reminder on crash
Browse files Browse the repository at this point in the history
  • Loading branch information
colinrotherham committed Oct 2, 2018
1 parent 0993c2d commit 659c088
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 9 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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:
Expand Down
30 changes: 21 additions & 9 deletions gulp/nodemon.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
})

0 comments on commit 659c088

Please sign in to comment.