-
Notifications
You must be signed in to change notification settings - Fork 6
/
index.js
executable file
·63 lines (45 loc) · 1.34 KB
/
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#!/usr/bin/env node
(function(){
"use strict";
var rc = require("rc");
var chalk = require("chalk");
var validator = require("validator");
var runner = require("./lib/runner.js");
var reporter = require("./lib/reporter.js");
var config = rc("testbox-runner", {});
// validate the configuration
var errors = [];
config.recurse = validator.toBoolean(config.recurse);
if (!validator.isURL(config.runner, {
require_tld: false,
require_protocol: true
})) {
errors.push("--runner is required and must be a URL");
}
if (!validator.isLength(config.directory, 1) && !validator.isLength(config.bundles, 1)) {
errors.push("--directory or --bundles must be provided");
}
if (errors.length) {
console.error("There was a problem with your configuration settings. Check your .testbox-runnerrc file or pass the proper command line arguments".red);
errors.forEach(function(err){
console.error(chalk.red(err));
});
return;
}
// option to force chalk
if (config.chalk) {
chalk.enabled = true;
}
runner(config, function(uri){
console.log("Running tests via URL:", uri);
console.log();
}, function(error, results){
if (error) {
console.error(error);
process.exitCode = 1
return;
}
reporter(results, config);
process.exitCode = (results.totalFail > 0 || results.totalError > 0) ? 1 : 0;
});
})();