Skip to content

Commit de3e7a8

Browse files
committed
feat(app): added grunt serve:debug task that launches the server with a node-inspector
closes #102
1 parent 3799c13 commit de3e7a8

File tree

2 files changed

+57
-1
lines changed

2 files changed

+57
-1
lines changed

Diff for: templates/common/Gruntfile.js

+53
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,40 @@ module.exports = function (grunt) {
170170
}
171171
},
172172

173+
// Debugging with node inspector
174+
'node-inspector': {
175+
custom: {
176+
options: {
177+
'web-host': 'localhost'
178+
}
179+
}
180+
},
181+
182+
// Use nodemon to run server in debug mode with an initial breakpoint
183+
nodemon: {
184+
debug: {
185+
script: 'server.js',
186+
options: {
187+
nodeArgs: ['--debug-brk'],
188+
env: {
189+
PORT: process.env.PORT || 9000
190+
},
191+
callback: function (nodemon) {
192+
nodemon.on('log', function (event) {
193+
console.log(event.colour);
194+
});
195+
196+
// opens browser on initial server start
197+
nodemon.on('config:update', function () {
198+
setTimeout(function () {
199+
require('open')('http://localhost:8080/debug?port=5858');
200+
}, 500);
201+
});
202+
}
203+
}
204+
}
205+
},
206+
173207
// Automatically inject Bower components into the app
174208
'bower-install': {
175209
app: {<% if (jade) { %>
@@ -386,6 +420,15 @@ module.exports = function (grunt) {
386420
'compass'<% } else { %>
387421
'copy:styles'<% } %>
388422
],
423+
debug: {
424+
tasks: [
425+
'nodemon',
426+
'node-inspector'
427+
],
428+
options: {
429+
logConcurrentOutput: true
430+
}
431+
},
389432
dist: [<% if (coffee) { %>
390433
'coffee',<% } %><% if (compass) { %>
391434
'compass:dist',<% } else { %>
@@ -465,6 +508,16 @@ module.exports = function (grunt) {
465508
return grunt.task.run(['build', 'express:prod', 'open', 'express-keepalive']);
466509
}
467510

511+
if (target === 'debug') {
512+
return grunt.task.run([
513+
'clean:server',
514+
'bower-install',
515+
'concurrent:server',
516+
'autoprefixer',
517+
'concurrent:debug'
518+
]);
519+
}
520+
468521
grunt.task.run([
469522
'clean:server',
470523
'bower-install',

Diff for: templates/common/_package.json

+4-1
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,10 @@
5757
"grunt-mocha-test": "~0.8.1",
5858
"supertest": "~0.8.2",
5959
"should": "~2.1.0",
60-
"grunt-env": "~0.4.1"
60+
"grunt-env": "~0.4.1",
61+
"grunt-node-inspector": "~0.1.3",
62+
"grunt-nodemon": "~0.2.0",
63+
"open": "~0.0.4"
6164
},
6265
"engines": {
6366
"node": ">=0.10.0"

0 commit comments

Comments
 (0)