From 71d63f0a704a2773cee368b1af24c188e04d0ae3 Mon Sep 17 00:00:00 2001 From: Tyler Henkel Date: Thu, 13 Feb 2014 20:00:46 -0500 Subject: [PATCH] fix(server): livereload now waits for server to finish restarting closes #42 --- templates/common/Gruntfile.js | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/templates/common/Gruntfile.js b/templates/common/Gruntfile.js index 8f9c9e299..58c243660 100644 --- a/templates/common/Gruntfile.js +++ b/templates/common/Gruntfile.js @@ -94,7 +94,7 @@ module.exports = function (grunt) { 'server.js', 'lib/**/*.{js,json}' ], - tasks: ['newer:jshint:server', 'express:dev'], + tasks: ['newer:jshint:server', 'express:dev', 'wait'], options: { livereload: true, nospawn: true //Without this option specified express won't be reloaded @@ -427,6 +427,18 @@ module.exports = function (grunt) { } }); + // Used for delaying livereload until after server has restarted + grunt.registerTask('wait', function () { + grunt.log.ok('Waiting for server reload...'); + + var done = this.async(); + + setTimeout(function () { + grunt.log.writeln('Done waiting!'); + done(); + }, 500); + }); + grunt.registerTask('express-keepalive', 'Keep grunt running', function() { this.async(); });