From 125ab4f88a7cf49fd7df32264a9847847e2326ca Mon Sep 17 00:00:00 2001 From: Vojta Jina Date: Sat, 26 Jan 2013 11:48:01 -0800 Subject: [PATCH] feat: allow plugins // in testacular.conf.js plugins = ['some-plugin'] The 'some-plugin' will be required as a node module, it needs to be DI module. // some-plugin.js module.exports = { 'preprocessor:coffee': ['factory', function(){}] }; --- lib/config.js | 3 ++- lib/server.js | 31 ++++++++++++++++++++----------- 2 files changed, 22 insertions(+), 12 deletions(-) diff --git a/lib/config.js b/lib/config.js index 15a533283..b175b93ab 100644 --- a/lib/config.js +++ b/lib/config.js @@ -131,7 +131,8 @@ var parseConfig = function(configFilePath, cliOptions) { type: 'html', dir: 'coverage/' }, - loggers: [ constant.CONSOLE_APPENDER ] + loggers: [ constant.CONSOLE_APPENDER ], + plugins: [] }; var ADAPTER_DIR = __dirname + '/../adapter'; diff --git a/lib/server.js b/lib/server.js index 65a80f518..3d24c8472 100644 --- a/lib/server.js +++ b/lib/server.js @@ -229,17 +229,26 @@ start.$inject = ['injector', 'config', 'launcher', 'emitter', 'preprocess', 'fil exports.start = function(cliOptions, done) { - var injector = new di.Injector([ - ['done', 'value', done || process.exit], - ['emitter', 'type', EventEmitter], - ['launcher', 'type', Launcher], - ['config', 'value', cfg.parseConfig(cliOptions.configFile, cliOptions)], - ['preprocess', 'factory', preprocessor.createPreprocessor], - ['fileList', 'type', FileList], - ['webServer', 'factory', ws.createWebServer], - ['reporter', 'factory', reporter.createReporters], - ['capturedBrowsers', 'type', browser.Collection] - ]); + var config = cfg.parseConfig(cliOptions.configFile, cliOptions); + var modules = [{ + logger: ['value', logger], + done: ['value', done || process.exit], + emitter: ['type', EventEmitter], + launcher: ['type', Launcher], + config: ['value', config], + preprocess: ['factory', preprocessor.createPreprocessor], + fileList: ['type', FileList], + webServer: ['factory', ws.createWebServer], + reporter: ['factory', reporter.createReporters], + capturedBrowsers: ['type', browser.Collection] + }]; + + // register all plugins + config.plugins.forEach(function(plugin) { + modules.push(require('../plugins/' + plugin)); + }); + + var injector = new di.Injector(modules); injector.invoke(start); };