-
Notifications
You must be signed in to change notification settings - Fork 0
/
Jakefile.js
185 lines (159 loc) · 4.49 KB
/
Jakefile.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
175
176
177
178
179
180
181
182
183
184
185
/*global task, desc, fail, complete */
"use strict";
var fs = require("fs");
var child_process = require("child_process");
var Ronn = require("ronn").Ronn;
var rimraf = require("rimraf");
var walkdir = require("walkdir");
var version = require("./lib/package-metadata").readPackageSync().version;
function nuke(dir, completer) {
rimraf(dir, function (err) {
if (err) {
fail(err);
} else if ("function" === typeof completer) {
completer();
}
});
}
function spawn(command, args, completer) {
child_process.spawn(command, args, {
stdio: "inherit",
customFds: [0, 1, 2]
}).on("exit", function (code) {
if (code !== 0) {
fail(command + " " + args.join(" ") +
" failed with " + code);
} else if ("function" === typeof completer) {
completer();
}
});
}
function bin(name, args, completer) {
if (!args) {
args = [];
}
spawn("node", ["node_modules/.bin/" + name].concat(args), completer);
}
function getTestFiles(subdirectory) {
var path = "test/" + subdirectory,
jsFilter = new RegExp(".js$"),
jsTestFiles = fs.readdirSync(path).filter(function (elem, index, arr) {
return jsFilter.test(elem);
}).map(function (file) {
return path + "/" + file;
});
return jsTestFiles;
}
function getJsFiles(path, cb) {
var files = [],
jsFilter = new RegExp(".js$"),
walker = walkdir(path, {
follow_symlinks: false
});
walker.on("file", function (filename, stat) {
if (jsFilter.test(filename)) {
files.push(filename);
}
});
walker.on("end", function () {
cb(files);
});
}
desc("Default: install all modules including devDependencies");
task("default", ["install"]);
desc("Install all modules including devDependencies");
task("install", function () {
var dep = jake.Task['dep'];
dep.addListener('complete', function () {
spawn("npm", ["install"], complete);
});
dep.invoke();
}, {
async: true
});
desc("Run all of Yeti's functional tests");
task("test-functional", function () {
var args = ["--spec"];
bin("vows", args.concat(getTestFiles("functional")), complete);
}, {
async: true
});
desc("Run all of Yeti's unit tests");
task("test-unit", function () {
var args = [];
if (process.env.TRAVIS) {
args.push("--spec");
}
bin("vows", args.concat(getTestFiles("unit")), complete);
}, {
async: true
});
desc("Run all of Yeti's tests");
task("test", ["test-functional", "test-unit"]);
/*
desc("Run all of Yeti's unit tests with the '--spec' flag");
task("spec", ["dep"], function () {
bin("vows", ["--spec"].concat(getTestFiles()), complete);
}, {
async: true
});
*/
desc("Report functional test coverage as HTML");
task("coverage-functional", function () {
spawn("bash", ["scripts/coverage.sh", "functional"], complete);
}, {
async: true
});
desc("Report unit test coverage as HTML");
task("coverage-unit", function () {
spawn("bash", ["scripts/coverage.sh", "unit"], complete);
}, {
async: true
});
desc("Report test coverage as HTML");
task("coverage", ["coverage-functional", "coverage-unit"]);
desc("Build HTML documentation");
task("html", function () {
fs.readFile("README.md", "utf8", function (err, data) {
var md, html;
// Remove Travis info
md = data.split("\n").slice(4).join("\n"),
html = new Ronn(md).html()
.replace(/<[\/]*html>/, "")
.replace("<pre>", '<pre class="code"');
fs.writeFileSync("doc/quick-start/index.mustache", html);
bin("selleck", [], complete);
});
}, {
async: true
});
desc("Build API documentation");
task("html-api", ["html"], function () {
bin("yuidoc", ["--project-version", version], complete);
}, {
async: true
});
desc("Run JSLint on all files, or a specific given file");
task("lint", function () {
getJsFiles("./lib", function (files) {
bin("jshint", files, complete);
});
}, {
async: true
});
desc("Remove build documentation");
task("clean", function () {
nuke("build_docs");
});
desc("Remove development tools");
task("maintainer-clean", function () {
spawn("rpm", ["rm", "webkit-devtools-agent"]);
nuke("tools");
});
desc("Fetch external dependencies");
task("dep", function () {
jake.mkdirP('dep/dev');
spawn(process.argv[0], ["./scripts/fetch_deps.js", "--dev"], complete);
}, {
async: true
});