forked from wtcross/grunt-lab
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGruntfile.js
86 lines (70 loc) · 1.73 KB
/
Gruntfile.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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
"use strict";
var path = require("path");
function localCommand (command) {
return path.join(__dirname, "node_modules", ".bin", command);
}
module.exports = function (grunt) {
var _ = grunt.util._;
var sourceFiles = [ "*.js", "tasks/**/*.js" ];
var testFiles = [ "test/**/*_spec.js" ];
var allFiles = sourceFiles.concat(testFiles);
var defaultJsHintOptions = grunt.file.readJSON("./.jshint.json");
var testJsHintOptions = _.extend(
grunt.file.readJSON("./test/.jshint.json"),
defaultJsHintOptions
);
grunt.config.init({
jscs : {
src : allFiles,
options : {
config : ".jscs.json"
}
},
jshint : {
src : sourceFiles,
options : defaultJsHintOptions,
test : {
options : testJsHintOptions,
files : {
test : testFiles
}
}
},
watch : {
scripts : {
files : allFiles,
tasks : [ "lint", "style" ],
options : {
spawn : false,
},
},
}
});
// Load plugins
grunt.loadNpmTasks("grunt-contrib-watch");
grunt.loadNpmTasks("grunt-contrib-jshint");
grunt.loadNpmTasks("grunt-jscs");
// Register tasks
grunt.registerTask("test", "Run all tests.", function () {
var done = this.async();
var options = {
args : [ "-c", "-t", 100, "-p" ],
cmd : localCommand("lab"),
opts : {
stdio : "inherit"
}
};
grunt.util.spawn(options, function (error) {
if (error) {
grunt.log.writeln();
grunt.log.error("Some tests failed.");
grunt.fail.fatal(error);
}
grunt.log.ok("All tests passed.");
done();
});
});
grunt.registerTask("lint", "Check for common code problems.", [ "jshint" ]);
grunt.registerTask("style", "Check for style conformity.", [ "jscs" ]);
grunt.registerTask("default", [ "lint", "style", "test" ]);
};