matrix:
fast_finish: true
sudo: false
+cache:
+ directories: tmp
"use strict";
var createHash = require("crypto").createHash;
+var fetch = require("./fetch");
var fork = require("child_process").fork;
var args = process.argv.slice(2);
if (!args.length) {
output: 0,
log: ""
};
- require(url.slice(0, url.indexOf(":"))).get(url, function(res) {
+ fetch(url, function(err, res) {
+ if (err) throw err;
var uglifyjs = fork("bin/uglifyjs", args, { silent: true });
res.on("data", function(data) {
results[url].input += data.length;
--- /dev/null
+var fs = require("fs");
+var path = require("path");
+
+try {
+ fs.mkdirSync("./tmp");
+} catch (e) {
+ if (e.code != "EEXIST") throw e;
+}
+
+function local(url) {
+ return path.join("./tmp", encodeURIComponent(url));
+}
+
+function read(url) {
+ return fs.createReadStream(local(url));
+}
+
+module.exports = function(url, callback) {
+ var result = read(url);
+ result.on("error", function(e) {
+ if (e.code != "ENOENT") return callback(e);
+ require(url.slice(0, url.indexOf(":"))).get(url, function(res) {
+ if (res.statusCode !== 200) return callback(res);
+ res.pipe(fs.createWriteStream(local(url)).on("close", function() {
+ callback(null, read(url));
+ }));
+ });
+ }).on("open", function() {
+ callback(null, result);
+ });
+};
}
args.push("--timings");
var child_process = require("child_process");
+ var fetch = require("./fetch");
var http = require("http");
var server = http.createServer(function(request, response) {
request.resume();
var url = site + request.url;
- http.get(url, function(res) {
- response.writeHead(res.statusCode, {
- "Content-Type": res.headers["content-type"]
+ fetch(url, function(err, res) {
+ if (err) throw err;
+ response.writeHead(200, {
+ "Content-Type": {
+ css: "text/css",
+ js: "application/javascript",
+ png: "image/png"
+ }[url.slice(url.lastIndexOf(".") + 1)] || "text/html; charset=utf-8"
});
if (/\.js$/.test(url)) {
var stderr = "";
var assert = require("assert");
+var semver = require("semver");
var spawn = require("child_process").spawn;
if (!process.env.UGLIFYJS_TEST_ALL) return;
});
});
+if (semver.satisfies(process.version, "0.12")) return;
describe("test/jetstream.js", function() {
this.timeout(20 * 60 * 1000);
[