Skip to content

Instantly share code, notes, and snippets.

@elmariofredo
Forked from webdesserts/Gulpfile.js
Last active August 29, 2015 14:01
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 elmariofredo/419d399001875f80173b to your computer and use it in GitHub Desktop.
Save elmariofredo/419d399001875f80173b to your computer and use it in GitHub Desktop.
var gulp = require('gulp'),
spawn = require('child_process').spawn,
node;
var startServer = function() {
if (node) node.kill()
node = spawn('node', ['--harmony', 'index.js'], {
stdio: 'inherit'
})
node.on('close', function(code) {
if (code === 8) {
gulp.log('Error detected, waiting for changes...');
}
});
};
/**
* $ gulp server
* description: launch the server. If there's a server already running, kill it.
*/
gulp.task('server', function() {
startServer();
});
/**
* $ gulp
* description: start the development environment
*/
gulp.task('default', function() {
startServer();
gulp.watch(['./index.js', '**/*.js', '../lib/*.js'], ['server'])
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment