Skip to content

Commit

Permalink
feat: allow plugins
Browse files Browse the repository at this point in the history
// 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(){}]
};
  • Loading branch information
vojtajina committed Feb 2, 2013
1 parent 172bf8d commit 125ab4f
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 12 deletions.
3 changes: 2 additions & 1 deletion lib/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down
31 changes: 20 additions & 11 deletions lib/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
};

0 comments on commit 125ab4f

Please sign in to comment.