Skip to content

Instantly share code, notes, and snippets.

@cappuccino
Created November 5, 2009 07:12
Show Gist options
  • Save cappuccino/226843 to your computer and use it in GitHub Desktop.
Save cappuccino/226843 to your computer and use it in GitHub Desktop.
var compressor = null;
function sharedCompressor()
{
if (!compressor) { print("here...");
compressor = OS.popen("java -server -Dfile.encoding=UTF-8 -classpath " + RHINO_PATH + ":" + SHRINKSAFE_PATH + " org.dojotoolkit.shrinksafe.Main");print("ok!");
}
return compressor;
}
function compress(/*String*/ aCode, /*String*/ FIXME)
{
print("called compress: " + aCode.length);
var tmpFile = FILE.join("/tmp", FIXME + Math.random() + ".tmp");
FILE.write(tmpFile, aCode, { charset:"UTF-8" });
var compressor = sharedCompressor();
output = "",
chunk = "";
print("1");
compressor.stdin.write(tmpFile + "\n");
print("2");
while (chunk = compressor.stdout.read())
{
output += chunk;
print("x");
}
return output;
// return OS.command(["java", "-Dfile.encoding=UTF-8", "-classpath", [RHINO_PATH, SHRINKSAFE_PATH].join(":"), "org.dojotoolkit.shrinksafe.Main", tmpFile]);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment