This repository has been archived by the owner on Sep 7, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 37
/
build
executable file
·115 lines (103 loc) · 3.23 KB
/
build
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
#!/usr/bin/env node
var path = require("path");
var util = require("util");
var exec = require("child_process").exec;
var fs = require("fs");
var jsp = require("uglify-js").parser;
var pro = require("uglify-js").uglify;
var files = [];
var read = 0;
function minify(script) {
var ast = jsp.parse(script);
ast = pro.ast_mangle(ast);
ast = pro.ast_squeeze(ast);
return pro.gen_code(ast);
}
function wrap(script) {
// return "(function () { var when; function define(cb) { when = cb(); } " +
// script + ";return buster; }());";
return script;
}
function finish() {
if (read == fileNames.length) {
var fileName = path.resolve(process.cwd(), "resources/buster-test.js");
var contents = wrap(files.join("\n"));
if (process.argv[2] == "--minify" || process.argv[2] == "-m") {
contents = minify(contents);
}
fs.writeFile(fileName, contents, function (err) {
if (err) {
console.log("Failed building resources/buster-test.js: " + err.message);
} else {
var kb = Math.floor(contents.length / 10.24) / 100;
console.log("Built resources/buster-test.js (" + kb + "kB)");
}
});
}
}
var fileNames = [
// buster/bundle-0.x.js
"when/dist/browser/when.js",
"lodash/index",
"async/lib/async",
"platform/platform",
"lib/buster/amd-shim.js",
"bane/lib/bane",
"samsam/lib/samsam",
"evented-logger/lib/evented-logger",
"referee/lib/expect",
"referee/lib/referee",
"formatio/lib/formatio",
"stack-filter/lib/stack-filter",
"sinon/lib/sinon",
"sinon/lib/sinon/spy",
"sinon/lib/sinon/call",
"sinon/lib/sinon/behavior",
"sinon/lib/sinon/stub",
"sinon/lib/sinon/mock",
"sinon/lib/sinon/collection",
"sinon/lib/sinon/sandbox",
"sinon/lib/sinon/match",
"sinon/lib/sinon/util/event",
"sinon/lib/sinon/util/fake_xml_http_request",
"sinon/lib/sinon/util/fake_timers",
"sinon/lib/sinon/util/fake_server",
"sinon/lib/sinon/util/fake_server_with_clock",
"buster-test/lib/seedrandom",
"buster-test/lib/browser-env",
"buster-test/lib/test-context",
"buster-test/lib/spec",
"buster-test/lib/test-case",
"buster-test/lib/test-runner",
// "buster-test/lib/reporters/json-proxy",
"buster-test/lib/reporters/html",
"buster-test/lib/reporters/html2",
"buster-test/lib/reporters",
"buster-test/lib/auto-run",
"referee-sinon/lib/referee-sinon",
"buster-sinon/lib/buster-sinon",
"lib/buster/buster-wiring.js",
"lib/buster/browser-wiring.js",
// buster/compat-0.x.js
"sinon/lib/sinon/util/timers_ie",
"sinon/lib/sinon/util/xhr_ie",
// buster/buster-0.7.x.js
// "buster/expose-modules",
// "stack-filter/lib/stack-filter",
// "buster-test/lib/reporters/html",
// "buster-test/lib/reporters/html2"
"lib/buster.js"
];
fileNames.forEach(function (fileName, i) {
try {
fileName = require.resolve(fileName);
} catch (e) {
fileName = path.resolve(process.cwd(), fileName);
}
fs.readFile(fileName, "utf-8", function (err, data) {
if (err) throw err;
files[i] = data;
read += 1;
finish();
});
});