Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 13 additions & 8 deletions Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -130,14 +130,19 @@ module.exports = function(grunt) {
// plugin's task(s), then test the result.
grunt.registerTask('test', [
'clean',
'express:defaults', 'nodeunit:defaults',
'express:custom_cmd', 'nodeunit:custom_cmd',
'express:custom_args', 'nodeunit:custom_args',
'express:custom_port', 'nodeunit:custom_port',
'express:custom_node_env', 'nodeunit:custom_node_env',
'express:custom_delay', 'nodeunit:custom_delay',
'express:custom_output', 'nodeunit:custom_output',
'express:stoppable', 'express:stoppable:stop', 'nodeunit:stoppable'
'express:defaults', 'nodeunit:defaults', 'express:defaults:stop',
'express:custom_cmd', 'nodeunit:custom_cmd', 'express:custom_cmd:stop',
'express:custom_args', 'nodeunit:custom_args', 'express:custom_args:stop',
'express:custom_port', 'nodeunit:custom_port', 'express:custom_port:stop',
'express:custom_node_env', 'nodeunit:custom_node_env', 'express:custom_node_env:stop',
'express:custom_delay', 'nodeunit:custom_delay', 'express:custom_delay:stop',
'express:custom_output', 'nodeunit:custom_output', 'express:custom_output:stop',
'express:stoppable', 'express:stoppable:stop', 'nodeunit:stoppable',

// Multiple servers
'express:custom_port', 'express:defaults',
'nodeunit:defaults', 'nodeunit:custom_port',
'express:custom_port:stop', 'express:defaults:stop',
]);

// By default, lint and run all tests.
Expand Down
10 changes: 8 additions & 2 deletions tasks/express.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,15 @@ var path = require('path');

module.exports = function(grunt) {

var server = require('./lib/server')(grunt);
var servers = {};

grunt.registerMultiTask('express', 'Start an express web server', function() {
if (!servers[this.target]) {
servers[this.target] = require('./lib/server')(grunt);
}

var server = servers[this.target];
var action = this.args.shift() || 'start';
var options = this.options({
cmd: process.argv[0],
args: [ ],
Expand All @@ -38,6 +44,6 @@ module.exports = function(grunt) {
return false;
}

server.start(options);
server[action](options);
});
};