-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathgrunt.js
More file actions
89 lines (78 loc) · 1.91 KB
/
grunt.js
File metadata and controls
89 lines (78 loc) · 1.91 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
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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
module.exports = function (grunt) {
grunt.initConfig({
lint: {
all: [ "src/**/*.js" ]
},
test: {
all: [ "test/unit/**/*.js" ]
},
jshint: {
options: {
"es5": true,
"node": true,
"globalstrict": true,
"strict": true,
"white": true,
"smarttabs": true
}
}
});
grunt.registerTask("default", "lint test");
grunt.registerTask("browserify", "Builds a browserified copy of JSHint", function () {
var browserify = require("browserify");
var bundle = browserify({ debug: true });
bundle.addEntry("./src/jshint.js");
grunt.file.mkdir("./dist");
grunt.file.write("./dist/jshint.js", bundle.bundle());
});
grunt.registerTask("cover", "Shows the test coverage report", function () {
var coveraje, done, runHelper, countdown;
var fileCount = 0;
var tests = {};
var useServer = !!grunt.option("server");
try {
coveraje = require("coveraje");
} catch (ex) {
grunt.log.error('coveraje not installed. '.red +
'Use "' + 'npm install coveraje'.bold + '"');
return false;
}
done = this.async();
runHelper = coveraje.runHelper;
grunt.file.expandFiles(grunt.config("test.all")).forEach(function (f) {
fileCount++;
tests[f] = function (context, instance) {
return runHelper("nodeunit", { reporterName: "minimal" })
.run(f)
.onComplete(function () {
if (!useServer)
countdown.one();
})
;
};
});
if (!useServer) {
countdown = runHelper.createCountdown(
runHelper
.createEmitter(function () {})
.onComplete(function () {
setTimeout(done, 200);
})
.onError(function () {
done(false, "timeout");
}),
fileCount,
5000
);
}
var c = coveraje.cover(
"var jshint = require(require('path').join('" + __dirname.replace(/\\/g, "\\\\") + "', 'src', 'jshint.js'));",
tests,
{
useServer: useServer,
globals: "node",
resolveRequires: ["*"]
}
);
});
};