This repository has been archived by the owner on Jun 26, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGruntfile.js
102 lines (88 loc) · 2.31 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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
var TAB_SIZE_CSS = 'pre{-moz-tab-size:4;-o-tab-size:4;-webkit-tab-size:4;-ms-tab-size:4;tab-size:4;}';
function mochaCommand(reporter) {
return "./node_modules/mocha/bin/mocha --ui tdd --reporter " + reporter + " --recursive tests";
}
function docsCommand(command) {
if (typeof command !== "string") {
command = command.join(" && ");
}
return "mkdir -p docs && " + command;
}
module.exports = function(grunt) {
grunt.initConfig({
pkg: grunt.file.readJSON("package.json"),
files: {
src: ["src/**/*.js"],
tests: ["tests/tests/**/*.js"],
watch: ["Gruntfile.js", "<%= files.src %>", "<%= files.tests %>"]
},
concat: {
dist: {
src: ["<%= files.src %>"],
dest: "dist/variadic.js"
}
},
jshint: {
options: {
sub: true,
boss: true,
smarttabs: true
},
files: ["<%= files.watch %>"],
},
uglify: {
options: {
banner: '/* Variadic.js - by William Bowers */\n'
},
dist: {
files: {
"dist/variadic.min.js": ["<%= concat.dist.dest %>"]
}
}
},
exec: {
"test": {
command: mochaCommand("dot")
},
"test-verbose": {
command: mochaCommand("spec")
},
"coverage": {
command: docsCommand([
"jscoverage --no-highlight src src-cov",
"COVERAGE=1 " + mochaCommand("html-cov") + " > docs/coverage.html"
])
},
"docco": {
command: docsCommand([
"./node_modules/docco/bin/docco <%= concat.dist.dest %>",
'echo "' + TAB_SIZE_CSS + '" >> docs/docco.css'
])
}
},
watch: {
build: {
files: "<%= files.watch %>",
tasks: "build"
},
test: {
files: "<%= files.watch %>",
tasks: "test"
}
}
});
grunt.loadNpmTasks("grunt-contrib-concat");
grunt.loadNpmTasks("grunt-contrib-jshint");
grunt.loadNpmTasks("grunt-contrib-uglify");
grunt.loadNpmTasks("grunt-contrib-watch");
grunt.loadNpmTasks("grunt-exec");
grunt.registerTask("test", "exec:test");
grunt.registerTask("test-verbose", "exec:test-verbose");
grunt.registerTask("docs:annotated-source", "exec:docco");
grunt.registerTask("docs:coverage", "exec:coverage");
grunt.registerTask("docs", ["build", "docs:annotated-source", "docs:coverage"]);
grunt.registerTask("lint", "jshint");
grunt.registerTask("min", "uglify");
grunt.registerTask("build", ["lint", "concat", "min"]);
grunt.registerTask("default", "watch:build");
};