-
Notifications
You must be signed in to change notification settings - Fork 7
/
Gruntfile.js
174 lines (159 loc) · 3.96 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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
/*global module */
module.exports = function (grunt) {
// Project configuration.
grunt.initConfig({
pkg: grunt.file.readJSON("package.json"),
jshint: {
all: [
"Gruntfile.js",
"*.js", // this will get things in dapp directory
"controllers/**/*.js",
"utils/**/*.js",
"modules/**/*.js",
"widgets/**/*.js",
"tests/**/*.js",
"!tests/intern.js",
"!tests/intern.local.js"
],
options: {
jshintrc: ".jshintrc"
}
},
// Before generating any new files, remove any previously-created files.
clean: {
tests: ["tmp"]
},
jsbeautifier: {
files: ["Gruntfile.js",
"*.js", // this will get things in dapp directory
"controllers/**/*.js",
"utils/**/*.js",
"modules/**/*.js",
"widgets/**/*.js",
"tests/**/*.js",
"!tests/intern.js",
"!tests/intern.local.js"
],
options: {
config: ".jshintrc",
js: {
jslintHappy: true,
indentWithTabs: true
}
}
},
// Copied from grunt web site but not tested
uglify: {
options: {
banner: "/*! <%= pkg.name %> <%= grunt.template.today('yyyy-mm-dd') %> */\n"
},
build: {
src: "src/<%= pkg.name %>.js",
dest: "build/<%= pkg.name %>.min.js"
}
},
intern: {
local: {
options: {
runType: "runner",
config: "tests/intern.local",
reporters: [] // pass :runner to avoid logging STARTED & SKIPPED
}
},
remote: {
options: {
runType: "runner",
config: "tests/intern",
reporters: [] // pass :runner to avoid logging STARTED & SKIPPED
}
}
},
"jsdoc-amddcl": {
docs: {
files: [{
src: [
".",
"./controllers/delite",
"./README.md",
"./package.json"
],
// imports: [
// "../delite/out"
// ],
paths: {
"decor": "../../../../decor/docs/api/0.3.0/decor",
"delite": "../../../../delite/docs/api/0.3.0/delite",
"deliteful": "../../../../delite/docs/api/0.3.0/deliteful"
},
packagePathFormat: "${name}/docs/api/${version}"
}]
},
export: {
files: [{
args: [
"-X"
],
src: [
".",
"./list",
"./README.md",
"./package.json"
],
dest: "./out/doclets.json" //,
// imports: [
// "../delite/out"
// ]
}]
}
}
});
// Load plugins
grunt.loadNpmTasks("intern");
grunt.loadNpmTasks("grunt-contrib-jshint");
grunt.loadNpmTasks("grunt-jsbeautifier");
grunt.loadNpmTasks("jsdoc-amddcl");
grunt.loadNpmTasks("grunt-contrib-uglify");
// Aliases
grunt.registerTask("jsdoc", "jsdoc-amddcl");
// By default, lint and run all tests.
grunt.registerTask("default", ["jsbeautifier", "jshint"]);
// Testing.
// always specify the target e.g. grunt test:remote, grunt test:remote
// then add on any other flags afterwards e.g. runner, console, lcovhtml
var testTaskDescription = "Run this task instead of the intern task directly! \n" +
"Always specify the test target e.g. \n" +
"grunt test:local\n" +
"grunt test:local.android\n" +
"grunt test:local.ios\n" +
"grunt test:remote\n\n" +
"To override the default reporter 'customRunner' with the 'runner' reporter pass the runner flag e.g. \n" +
"grunt test:local:runner\n" +
"Add any optional reporters via a flag e.g. \n" +
"grunt test:local:console\n" +
"grunt test:local:lcovhtml\n" +
"grunt test:local:console:lcovhtml";
grunt.registerTask("test", testTaskDescription, function (target) {
function addReporter(reporter) {
var property = "intern." + target + ".options.reporters",
value = grunt.config.get(property);
if (value.indexOf(reporter) !== -1) {
return;
}
value.push(reporter);
grunt.config.set(property, value);
}
if (this.flags.lcovhtml) {
addReporter("lcovhtml");
}
if (this.flags.runner) {
addReporter("runner");
}
if (this.flags.console) {
addReporter("console");
}
if (!this.flags.runner || this.flags.customRunner) {
addReporter("dapp/tests/customRunner");
}
grunt.task.run("intern:" + target);
});
};