gimm / gulp-express

gulp plugin for express
56 stars 26 forks source link

Fixed a bug that causes gulp-express to throw error when running server.run for second time #28

Closed nathanbuchar closed 9 years ago

nathanbuchar commented 9 years ago

This line of code should be changed to listener.processExit, as processExitListener is not defined.

What we would expect:

gulp-express will kill the current node process and remove the exit listener before starting a new node process as defined in the source (lines 62–66):

// gulp-express/index.js:62

if (node) { // Stop
  node.kill('SIGKILL');
  node = undefined;
  process.removeListener('exit', processExitListener);
} ...

What we get:

ReferenceError: processExitListener is not defined is thrown when running server.run() after already running server.run() in order to restart the server.

Practical example

gulp.task('server:start', function () {
  server.run();
  ...
  gulp.watch('./app/**', ['server:restart']);
});

gulp.task('server:restart', function () {
  server.run(); // This will throw the error.
});