Skip to content

Commit

Permalink
feat(runner): support config files
Browse files Browse the repository at this point in the history
Closes #625
  • Loading branch information
vojtajina committed Aug 2, 2013
1 parent d4a06f2 commit 449e4a1
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 5 deletions.
2 changes: 1 addition & 1 deletion lib/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ var describeRun = function() {
.usage('Karma - Spectacular Test Runner for JavaScript.\n\n' +
'RUN - Run the tests (requires running server).\n\n' +
'Usage:\n' +
' $0 run [<options>]')
' $0 run [<configFile>] [<options>]')
.describe('port', '<integer> Port where the server is listening.')
.describe('no-refresh', 'Do not re-glob all the patterns.')
.describe('help', 'Print usage.');
Expand Down
2 changes: 2 additions & 0 deletions lib/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,8 @@ var CONFIG_SYNTAX_HELP = ' module.exports = function(config) {\n' +
var parseConfig = function(configFilePath, cliOptions) {
var configModule;
if (configFilePath) {
log.debug('Loading config %s', configFilePath);

try {
configModule = require(configFilePath);
} catch(e) {
Expand Down
10 changes: 6 additions & 4 deletions lib/runner.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ var http = require('http');

var constant = require('./constants');
var helper = require('./helper');
var cfg = require('./config');


var parseExitCode = function(buffer, defaultCode) {
var tailPos = buffer.length - Buffer.byteLength(constant.EXIT_CODE) - 1;
Expand All @@ -25,13 +27,13 @@ var parseExitCode = function(buffer, defaultCode) {
// TODO(vojta): read config file (port, host, urlRoot)
exports.run = function(config, done) {
done = helper.isFunction(done) ? done : process.exit;
config = cfg.parseConfig(config.configFile, config);

var exitCode = 1;
var options = {
hostname: 'localhost',
path: '/__run__',
// TODO(vojta): remove runnerPort in 0.11
port: config.port || config.runnerPort || constant.DEFAULT_PORT,
hostname: config.hostname,
path: config.urlRoot + 'run',
port: config.port,
method: 'POST',
headers: {
'Content-Type': 'application/json'
Expand Down

0 comments on commit 449e4a1

Please sign in to comment.