forked from tc39/test262-harness
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
35 lines (28 loc) · 916 Bytes
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
exports.Runner = require('./lib/runner')
exports.ConsoleRunner = require('./lib/runners/console')
exports.NodeRunner = require('./lib/runners/node')
exports.JSShellRunner = require('./lib/runners/jsshell')
var config = exports.config = {};
exports.useConfig = function(conf) {
Object.keys(conf).forEach(function(k) {
config[k] = conf[k];
})
}
exports.loadRunner = function loadRunner() {
if(typeof config.runner === 'string')
return requireRunner(config.runner);
if(typeof config.runner === 'function')
return config.runner;
if(config.consoleCommand)
return requireRunner('console')
return requireRunner('node');
}
function requireRunner(name) {
try {
return require('./lib/runners/' + name);
} catch(e) {
if(e.code === 'MODULE_NOT_FOUND')
throw new Error('Runner ' + name + ' not found.');
throw e;
}
}