forked from blackberry/bbUI.js
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Jakefile
63 lines (50 loc) · 1.69 KB
/
Jakefile
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
var DEPLOY = __dirname + "/pkg/",
_path = require('path'),
fs = require('fs');
function include(files, transform) {
files = files.map ? files : [files];
return files.map(function (file) {
var str = fs.readFileSync(file, "utf-8") + "\n";
return transform ? transform(str, file) : str;
}).join('\n');
}
function collect(path, files, matches) {
matches = matches || function (path) {
return path.match(/\.js$/);
};
if (fs.statSync(path).isDirectory()) {
fs.readdirSync(path).forEach(function (item) {
collect(_path.join(path, item), files, matches);
});
} else if (matches(path)) {
files.push(path);
}
}
desc("runs jake build");
task('default', ['build'], function () {});
desc("clean");
task('clean', [], function () {
var childProcess = require('child_process'),
cmd = 'rm -rf ' + DEPLOY + ' && ' +
'mkdir ' + DEPLOY;
childProcess.exec(cmd, complete);
}, true);
desc("package everything for a release");
task('build', ['clean'], function () {
var output = "",
css = "",
plugins = [];
output += include("LICENSE");
output += include("src/core.js");
collect(__dirname + "/src/plugins", plugins);
plugins.forEach(function (plugin) {
output += include(plugin);
});
output += "bb.assignBackHandler(bb.popScreen);";
fs.writeFileSync(__dirname + "/pkg/bbUI.js", output);
fs.writeFileSync(__dirname + "/samples/bbUI.js", output);
css += include("src/bbUI.css");
fs.writeFileSync(__dirname + "/pkg/bbUI.css", css);
fs.writeFileSync(__dirname + "/samples/bbUI.css", css);
console.log("Prepare ship for ludicrous speed!");
});