forked from ebdrup/nodeerrors
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrunTests.js
More file actions
35 lines (32 loc) · 1.03 KB
/
runTests.js
File metadata and controls
35 lines (32 loc) · 1.03 KB
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
"use strict";
var fs = require("fs");
var path = require("path");
runJsHint(["lib", "test", "bin"], function (err) {
if (err) {
console.error("Exiting because of jsHint errors");
return process.exit(1);
}
return runMocha();
});
function runMocha() {
var realProcessExit = process.exit;
process.exit = function(code){
setTimeout(realProcessExit.bind(process, code), 200);
};
require('../node_modules/mocha/bin/_mocha');
}
function runJsHint(pathsArray, callback) {
var jsHint = require("../node_modules/jshint/lib/hint.js");
var config = JSON.parse(fs.readFileSync(path.resolve(".jshintrc"), "utf-8"));
var reporter = require("../node_modules/jshint/lib/reporters/default.js").reporter;
var ignores = fs.readFileSync(path.resolve(".jshintignore"), "utf8").split("\n")
.filter(function (line) {
return !!line.trim(); //remove empty lines
})
.map(path.resolve);
var results = jsHint.hint(pathsArray, config, reporter, ignores);
if (results.length > 0) {
return callback(new Error("JSHintErrors"));
}
return callback(null);
}