Skip to content

Instantly share code, notes, and snippets.

@rharriso
Last active October 5, 2016 21:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rharriso/0ca89bdda639691759816860739c9442 to your computer and use it in GitHub Desktop.
Save rharriso/0ca89bdda639691759816860739c9442 to your computer and use it in GitHub Desktop.
/*
server-start starts up nodemon
the output is corrected to show new lines correctly.
*/
var nodemon = require('gulp-nodemon');
var replace = require('stream-replace');
var gutil = require('gulp-util');
// Start server with nodemon
gulp.task('server-start', function () {
var monitor = nodemon({
exec: 'node-inspector & node --debug', // load node inspector
script: './index.js',
ext: 'js jsx html',
watch: ['./folder/to/watch/'],
debug: true,
stdout: false,
readable: false,
verbose: true
});
// replace all the '\n's with new lines
monitor.on('readable', function () {
this.stdout.pipe(replace(/\\n/igm, '\n')).pipe(process.stdout);
this.stderr.pipe(replace(/\\n/igm, '\n')).pipe(process.stderr);
});
process.once('exit', function () {
gutil.log(gutil.colors.cyan('\'nodemon\''), 'handle process exit');
monitor.emit('exit');
});
process.once('SIGINT', function () {
gutil.log(gutil.colors.cyan('\'nodemon\''), 'handle SIGINT');
process.exit(1);
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment