Permalink
Fetching contributors…
Cannot retrieve contributors at this time
executable file 116 lines (103 sloc) 3.23 KB
#!/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();
});
});