Advertisement
Guest User

Untitled

a guest
Feb 20th, 2015
232
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. 'use strict';
  2.  
  3. var node;
  4. var gulp = require('gulp');
  5. var spawn = require('child_process').spawn;
  6.  
  7. var JS_SERVER_BIN_FILE = './bin/server.js';
  8. var JS_SERVER_SOURCE = './js/server/**/*.js';
  9.  
  10.  
  11. gulp.task('supervise', function() {
  12.     gulp.watch(JS_SERVER_SOURCE, function() {
  13.         if (node) node.kill();
  14.  
  15.         node = spawn('node', [JS_SERVER_BIN_FILE], {stdio: 'inherit'});
  16.         node.on('close', function (code) {
  17.             if (code === 8) {
  18.                 console.log('Error detected, waiting for changes...');
  19.             }
  20.         });
  21.     });
  22. });
  23.  
  24.  
  25. process.on('exit', function() {
  26.     if (node) node.kill()
  27. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement