Add CI command and server sigterm handler

This commit is contained in:
Josh Johnson 2018-10-10 12:44:08 +01:00
parent 7d3c8daf07
commit 3ce59432bc
2 changed files with 23 additions and 8 deletions

View file

@ -9,9 +9,10 @@
"build": "npm run js:build && npm run css:build",
"lint": "eslint assets/**/*.js",
"coverage": "nyc npm run test",
"cypress": "$(npm bin)/cypress run",
"test": "mocha --require ./config/test.js --compilers js:babel-core/register \"./src/**/**/**/**/*.test.js\"",
"test:watch": "npm run test -- --watch --inspect=5556",
"cypress": "$(npm bin)/cypress run",
"test:ci": "concurrently --kill-others --prefix-colors yellow,green \"npm run start\" \"npm run cypress\"",
"css:watch": "nodemon -e scss -x \"npm run css:build\"",
"css:build": "npm run css:sass -s && npm run css:prefix -s && npm run css:min -s",
"css:sass": "node-sass --output-style expanded --include-path scss src/styles/base.scss public/assets/styles/base.css && node-sass --output-style expanded --include-path scss src/styles/choices.scss public/assets/styles/choices.css",

View file

@ -16,21 +16,35 @@ if (process.env.NODE_ENV !== 'production') {
console.log('Compiling bundle... 👷🏽');
const compiler = webpack(config);
app.use(webpackDevMiddleware(compiler, {
publicPath: '/assets/scripts/',
stats: {
colors: true,
},
}));
app.use(
webpackDevMiddleware(compiler, {
publicPath: '/assets/scripts/',
stats: {
colors: true,
},
}),
);
app.use(webpackHotMiddleware(compiler));
}
app.use(express.static(DIST_DIR));
app.listen(PORT, (err) => {
const server = app.listen(PORT, err => {
if (err) {
console.log(err);
}
console.log(`Listening at http://localhost:${PORT} 👂`);
});
process.on('SIGTERM', () => {
if (server) {
server.close(() => {
console.log('Shutting down server');
process.exit(0);
});
} else {
process.exit(0);
}
});