Last active
October 5, 2016 21:00
-
-
Save rharriso/0ca89bdda639691759816860739c9442 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
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