diff --git a/lib/monitor/run.js b/lib/monitor/run.js index a67d05c7..cd143477 100644 --- a/lib/monitor/run.js +++ b/lib/monitor/run.js @@ -158,9 +158,22 @@ function run(options) { process.exit(); } - if (code === 2) { - // something wrong with parsed command + // If the command failed with code 2, it may or may not be a syntax error + // See: http://git.io/fNOAR + // We will only assume a parse error, if the child failed quickly + if (code === 2 && Date.now() < config.lastStarted + 500) { utils.log.error('process failed, unhandled exit code (2)'); + utils.log.error(''); + utils.log.error('Either the command has a syntax error,'); + utils.log.error('or it is exiting with reserved code 2.'); + utils.log.error(''); + utils.log.error('To keep nodemon running even after a code 2,'); + utils.log.error('add this to the end of your command: || exit 1'); + utils.log.error(''); + utils.log.error('Read more here: https://git.io/fNOAG'); + utils.log.error(''); + utils.log.error('nodemon will stop now so that you can fix the command.'); + utils.log.error(''); bus.emit('error', code); process.exit(); }