From de3e7a8b7e63c54090c8fbc2f51998965b2e274f Mon Sep 17 00:00:00 2001 From: Tyler Henkel Date: Thu, 27 Feb 2014 06:30:21 -0500 Subject: [PATCH] feat(app): added `grunt serve:debug` task that launches the server with a node-inspector closes #102 --- templates/common/Gruntfile.js | 53 ++++++++++++++++++++++++++++++++++ templates/common/_package.json | 5 +++- 2 files changed, 57 insertions(+), 1 deletion(-) diff --git a/templates/common/Gruntfile.js b/templates/common/Gruntfile.js index c07675551..3e0260b18 100644 --- a/templates/common/Gruntfile.js +++ b/templates/common/Gruntfile.js @@ -170,6 +170,40 @@ module.exports = function (grunt) { } }, + // Debugging with node inspector + 'node-inspector': { + custom: { + options: { + 'web-host': 'localhost' + } + } + }, + + // Use nodemon to run server in debug mode with an initial breakpoint + nodemon: { + debug: { + script: 'server.js', + options: { + nodeArgs: ['--debug-brk'], + env: { + PORT: process.env.PORT || 9000 + }, + callback: function (nodemon) { + nodemon.on('log', function (event) { + console.log(event.colour); + }); + + // opens browser on initial server start + nodemon.on('config:update', function () { + setTimeout(function () { + require('open')('http://localhost:8080/debug?port=5858'); + }, 500); + }); + } + } + } + }, + // Automatically inject Bower components into the app 'bower-install': { app: {<% if (jade) { %> @@ -386,6 +420,15 @@ module.exports = function (grunt) { 'compass'<% } else { %> 'copy:styles'<% } %> ], + debug: { + tasks: [ + 'nodemon', + 'node-inspector' + ], + options: { + logConcurrentOutput: true + } + }, dist: [<% if (coffee) { %> 'coffee',<% } %><% if (compass) { %> 'compass:dist',<% } else { %> @@ -465,6 +508,16 @@ module.exports = function (grunt) { return grunt.task.run(['build', 'express:prod', 'open', 'express-keepalive']); } + if (target === 'debug') { + return grunt.task.run([ + 'clean:server', + 'bower-install', + 'concurrent:server', + 'autoprefixer', + 'concurrent:debug' + ]); + } + grunt.task.run([ 'clean:server', 'bower-install', diff --git a/templates/common/_package.json b/templates/common/_package.json index a6ffe9e29..491435c22 100644 --- a/templates/common/_package.json +++ b/templates/common/_package.json @@ -57,7 +57,10 @@ "grunt-mocha-test": "~0.8.1", "supertest": "~0.8.2", "should": "~2.1.0", - "grunt-env": "~0.4.1" + "grunt-env": "~0.4.1", + "grunt-node-inspector": "~0.1.3", + "grunt-nodemon": "~0.2.0", + "open": "~0.0.4" }, "engines": { "node": ">=0.10.0"