From 7d036db30dd673496b9fe7f0290d3c6327e8086e Mon Sep 17 00:00:00 2001 From: Eric Clemmons Date: Thu, 17 Oct 2013 14:11:06 -0500 Subject: [PATCH 1/2] Servers are namespaced to target --- tasks/express.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/tasks/express.js b/tasks/express.js index f28258a..bfced4f 100644 --- a/tasks/express.js +++ b/tasks/express.js @@ -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: [ ], @@ -38,6 +44,6 @@ module.exports = function(grunt) { return false; } - server.start(options); + server[action](options); }); }; From 2c45ea9a821c7434957cd99eb73d7728f57b15e4 Mon Sep 17 00:00:00 2001 From: Eric Clemmons Date: Thu, 17 Oct 2013 14:11:16 -0500 Subject: [PATCH 2/2] Update tests to use :stop explicitly --- Gruntfile.js | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/Gruntfile.js b/Gruntfile.js index 1b98101..488cacc 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -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.