Skip to content

Commit

Permalink
feat(app): added grunt serve:debug task that launches the server wi…
Browse files Browse the repository at this point in the history
…th a node-inspector

closes #102
  • Loading branch information
DaftMonk committed Feb 27, 2014
1 parent 3799c13 commit de3e7a8
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 1 deletion.
53 changes: 53 additions & 0 deletions templates/common/Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) { %>
Expand Down Expand Up @@ -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 { %>
Expand Down Expand Up @@ -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',
Expand Down
5 changes: 4 additions & 1 deletion templates/common/_package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit de3e7a8

Please sign in to comment.