Skip to content
This repository was archived by the owner on Jan 27, 2018. It is now read-only.

Commit e77adf0

Browse files
author
Daniel Wirtz
committed
Compiler from official source
1 parent 69dc64f commit e77adf0

File tree

4 files changed

+77
-34
lines changed

4 files changed

+77
-34
lines changed

.gitignore

+4
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
11
node_modules
22
npm-debug.log
33
backup/
4+
jre/bin_windows
5+
jre/bin_linux
6+
jre/bin/mac
7+
jre/lib

compiler/compiler.jar

-5.95 MB
Binary file not shown.

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "closurecompiler",
3-
"version": "1.0.3",
3+
"version": "1.0.4",
44
"author": "Daniel Wirtz <[email protected]>",
55
"description": "Closure Compiler for node.js",
66
"contributors": [

scripts/configure.js

+72-33
Original file line numberDiff line numberDiff line change
@@ -26,48 +26,86 @@ var ClosureCompiler = require(__dirname+"/../ClosureCompiler.js"),
2626
child_process = require("child_process"),
2727
pkg = require(__dirname+"/../package.json");
2828

29+
console.log("Configuring ClosureCompiler.js "+pkg.version+" ...\n");
30+
31+
// Closure Compiler download url
32+
var ccUrl = "http://closure-compiler.googlecode.com/files/compiler-latest.zip";
33+
34+
// Temporary file for the download
35+
var ccTempFile = path.normalize(__dirname+path.sep+".."+path.sep+"compiler"+path.sep+"compiler.zip");
36+
2937
// Bundled JRE download url
3038
var jreUrl = "http://bundled-openjdk-jre.googlecode.com/files/OpenJDK-JRE-7u6_24.zip";
3139

3240
// Temporary file for the download
33-
var jreTempFile = __dirname+path.sep+".."+path.sep+"jre"+path.sep+"OpenJDK-JRE.zip";
41+
var jreTempFile = path.normalize(__dirname+path.sep+".."+path.sep+"jre"+path.sep+"OpenJDK-JRE.zip");
42+
43+
console.log(" Downloading Closure Compiler ...");
44+
var lastBytes = 0, currentBytes = 0, mb = 1024*1024;
45+
download(ccUrl, ccTempFile, function(error, bytes) {
46+
if (error) {
47+
console.log(" ✖ Download failed: "+error+"\n");
48+
fail();
49+
}
50+
console.log(" ✔ Download complete: "+ccTempFile+" ("+parseInt(bytes/mb, 10)+" mb)");
51+
unpack(ccTempFile, function(error) {
52+
if (error) {
53+
console.log(" ✖ Unpack failed: "+error+"\n");
54+
fail();
55+
}
56+
console.log(" ✔ Unpack complete.\n");
57+
configure_jre();
58+
});
59+
}, function(bytes, total) {
60+
currentBytes += bytes;
61+
if (currentBytes == bytes || currentBytes - lastBytes >= mb) {
62+
console.log(" | "+parseInt(currentBytes/mb, 10)+" / "+(total > 0 ? parseInt(total/mb, 10) : "???")+" mb");
63+
lastBytes = currentBytes;
64+
}
65+
});
3466

35-
// Test if there is already a global Java so we don't need to download anything
36-
console.log("Configuring ClosureCompiler.js "+pkg.version+" ...\n");
37-
ClosureCompiler.testJava(ClosureCompiler.getGlobalJava(), function(ok) {
38-
if (ok) {
39-
console.log(" ✔ Global Java is available, perfect!\n");
40-
// Travis CI for example has one, so we save their bandwidth. And Google's. And yours. And...
41-
finish();
42-
} else {
43-
console.log(" ✖ Global Java not found, we need to install the bundled JRE ...");
44-
console.log(" Downloading "+jreUrl+" ...");
45-
var lastBytes = 0, currentBytes = 0, mb = 1024*1024;
46-
download(jreUrl, jreTempFile, function(error, bytes) {
47-
if (error) {
48-
console.log(" ✖ Download failed: "+error+"\n");
49-
fail();
50-
}
51-
console.log(" ✔ Download complete: "+jreTempFile+" ("+parseInt(bytes/mb, 10)+" mb)");
52-
console.log(" Unpacking "+jreTempFile+" ...");
53-
unpack(jreTempFile, function(error) {
67+
/**
68+
* Configures the JRE.
69+
*/
70+
function configure_jre() {
71+
console.log(" Configuring JRE ...");
72+
73+
// Test if there is already a global Java so we don't need to download anything
74+
ClosureCompiler.testJava(ClosureCompiler.getGlobalJava(), function(ok) {
75+
if (ok) {
76+
console.log(" ✔ Global Java is available, perfect!\n");
77+
// Travis CI for example has one, so we save their bandwidth. And Google's. And yours. And...
78+
finish();
79+
} else {
80+
console.log(" ✖ Global Java not found, we need to install the bundled JRE ...");
81+
console.log(" Downloading "+jreUrl+" ...");
82+
lastBytes = 0; currentBytes = 0;
83+
download(jreUrl, jreTempFile, function(error, bytes) {
5484
if (error) {
55-
console.log(" ✖ Unpack failed: "+error+"\n");
85+
console.log(" ✖ Download failed: "+error+"\n");
5686
fail();
5787
}
58-
console.log(" ✔ Unpack complete.\n");
59-
configure();
60-
runTest();
88+
console.log(" ✔ Download complete: "+jreTempFile+" ("+parseInt(bytes/mb, 10)+" mb)");
89+
console.log(" Unpacking "+jreTempFile+" ...");
90+
unpack(jreTempFile, function(error) {
91+
if (error) {
92+
console.log(" ✖ Unpack failed: "+error+"\n");
93+
fail();
94+
}
95+
console.log(" ✔ Unpack complete.\n");
96+
configure();
97+
runTest();
98+
});
99+
}, function(bytes, total) {
100+
currentBytes += bytes;
101+
if (currentBytes == bytes || currentBytes - lastBytes >= mb) {
102+
console.log(" | "+parseInt(currentBytes/mb, 10)+" / "+(total > 0 ? parseInt(total/mb, 10) : "???")+" mb");
103+
lastBytes = currentBytes;
104+
}
61105
});
62-
}, function(bytes, total) {
63-
currentBytes += bytes;
64-
if (currentBytes == bytes || currentBytes - lastBytes >= mb) {
65-
console.log(" | "+parseInt(currentBytes/mb, 10)+" / "+(total > 0 ? parseInt(total/mb, 10) : "???")+" mb");
66-
lastBytes = currentBytes;
67-
}
68-
});
69-
}
70-
});
106+
}
107+
});
108+
}
71109

72110
/**
73111
* Downloads a file.
@@ -187,6 +225,7 @@ function runTest() {
187225
* Cleans up.
188226
*/
189227
function cleanUp() {
228+
try { fs.unlinkSync(ccTempFile); } catch (e) {}
190229
try { fs.unlinkSync(jreTempFile); } catch (e) {}
191230
// ...your harddrive's space.
192231
}

0 commit comments

Comments
 (0)