-
-
Save roboshoes/eb421ac6b7a9856b982c to your computer and use it in GitHub Desktop.
Automatically reload your node.js app on file change with Gulp (https://github.com/wearefractal/gulp).
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
var gulp = require( "gulp" ); | |
var spawn = require( "child_process" ).spawn; | |
var node; | |
gulp.task( "server", function() { | |
if ( node ) node.kill(); | |
node = spawn( "node", [ "app.js" ], { stdio: "inherit" } ); | |
node.on( "close", function( code ) { | |
if (code === 8) { | |
gulp.log( "Error detected, waiting for changes..." ); | |
} | |
} ); | |
} ); | |
gulp.task( "watch", function() { | |
gulp.watch( [ "./app.js" ], "server" ); | |
} ); | |
process.on( "exit", function() { | |
if ( node ) node.kill(); | |
} ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment