Skip to content
This repository was archived by the owner on Jun 5, 2020. It is now read-only.

Commit 5c7d4dd

Browse files
committed
Downgrade tar, fstream
1 parent 79f5a12 commit 5c7d4dd

File tree

4 files changed

+164
-11
lines changed

4 files changed

+164
-11
lines changed

compiler/README.md

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
11
# [Google Closure Compiler](https://developers.google.com/closure/compiler/)
22

3+
[![Build Status](https://travis-ci.org/google/closure-compiler.svg?branch=master)](https://travis-ci.org/google/closure-compiler)
4+
35
The [Closure Compiler](https://developers.google.com/closure/compiler/) is a tool for making JavaScript download and run faster. It is a true compiler for JavaScript. Instead of compiling from a source language to machine code, it compiles from JavaScript to better JavaScript. It parses your JavaScript, analyzes it, removes dead code and rewrites and minimizes what's left. It also checks syntax, variable references, and types, and warns about common JavaScript pitfalls.
46

57
## Getting Started
68
* [Download the latest version](http://dl.google.com/closure-compiler/compiler-latest.zip)
79
* See the [Google Developers Site](https://developers.google.com/closure/compiler/docs/gettingstarted_app) for documentation including instructions for running the compiler from the command line.
810

911
## Options for Getting Help
10-
1. Post in the [Closure Compiler Discuss Group] (https://groups.google.com/forum/#!forum/closure-compiler-discuss)
12+
1. Post in the [Closure Compiler Discuss Group](https://groups.google.com/forum/#!forum/closure-compiler-discuss)
1113
2. Ask a question on [Stack Overflow](http://stackoverflow.com/questions/tagged/google-closure-compiler)
1214
3. Consult the [FAQ](https://github.com/google/closure-compiler/wiki/FAQ)
1315

@@ -31,7 +33,7 @@ Note: The Closure Compiler requires [Java 7 or higher](http://www.java.com/).
3133
### Using [Eclipse](http://www.eclipse.org/)
3234
3335
1. Download and open the [Eclipse IDE](http://www.eclipse.org/).
34-
2. Navigate to ```File > New > Project ...``` and create a Java Projet. Give
36+
2. Navigate to ```File > New > Project ...``` and create a Java Project. Give
3537
the project a name.
3638
3. Select ```Create project from existing source``` and choose the root of the
3739
checked-out source tree as the existing directory.
@@ -41,10 +43,10 @@ Note: The Closure Compiler requires [Java 7 or higher](http://www.java.com/).
4143
4244
## Running
4345
44-
On the command line, type
46+
On the command line, at the root of this project, type
4547
4648
```
47-
java -jar compiler.jar
49+
java -jar build/compiler.jar
4850
```
4951
5052
This starts the compiler in interactive mode. Type
@@ -174,7 +176,7 @@ significantly for use by Google's JavaScript compiler.</td>
174176
<tr>
175177
<td>Local Modifications</td>
176178
<td>The packages have been renamespaced. All code not
177-
relevant to parsing has been removed. A JsDoc parser and static typing
179+
relevant to the parse tree has been removed. A JsDoc parser and static typing
178180
system have been added.</td>
179181
</tr>
180182
</table>
@@ -525,4 +527,4 @@ for the purpose of Test-driven Development (TDD) or Behavior Driven Development
525527
<td>Local Modifications</td>
526528
<td>Substantial changes to make them compatible with NpmCommandLineRunner.</td>
527529
</tr>
528-
</table>
530+
</table>

lib/follow-redirects.js

Lines changed: 152 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,152 @@
1+
// substitute underscore (dcode)
2+
var _ = {}; _.extend = function(obj) {
3+
Array.prototype.slice.call(arguments, 1).forEach(function(source) {
4+
if (source)
5+
for (var prop in source) {
6+
obj[prop] = source[prop];
7+
}
8+
});
9+
return obj;
10+
};
11+
12+
/*
13+
follow-redirects Copyright © 2014 Olivier Lalonde <[email protected]>
14+
15+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
16+
ocumentation files (the “Software”), to deal in the Software without restriction, including without limitation the
17+
rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit
18+
persons to whom the Software is furnished to do so, subject to the following conditions:
19+
20+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
21+
22+
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
23+
WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
24+
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
25+
OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
26+
*/
27+
// ref: https://github.com/olalonde/follow-redirects
28+
var nativeHttps = require('https'),
29+
nativeHttp = require('http'),
30+
url = require('url');
31+
32+
var maxRedirects = module.exports.maxRedirects = 5;
33+
34+
var protocols = {
35+
https: nativeHttps,
36+
http: nativeHttp
37+
};
38+
39+
// Only use GETs on redirects
40+
for (var protocol in protocols) {
41+
// h is either our cloned http or https object
42+
var h = function() {};
43+
h.prototype = protocols[protocol];
44+
h = new h();
45+
46+
module.exports[protocol] = h;
47+
48+
h.request = function (h) {
49+
return function (options, callback, redirectOptions) {
50+
51+
redirectOptions = redirectOptions || {};
52+
53+
var max = (typeof options === 'object' && 'maxRedirects' in options) ? options.maxRedirects : exports.maxRedirects;
54+
55+
var redirect = _.extend({
56+
count: 0,
57+
max: max,
58+
clientRequest: null,
59+
userCallback: callback
60+
}, redirectOptions);
61+
62+
/**
63+
* Emit error if too many redirects
64+
*/
65+
if (redirect.count > redirect.max) {
66+
var err = new Error('Max redirects exceeded. To allow more redirects, pass options.maxRedirects property.');
67+
redirect.clientRequest.emit('error', err);
68+
return redirect.clientRequest;
69+
}
70+
71+
redirect.count++;
72+
73+
/**
74+
* Parse URL from options
75+
*/
76+
var reqUrl;
77+
if (typeof options === 'string') {
78+
reqUrl = options;
79+
}
80+
else {
81+
reqUrl = url.format(_.extend({ protocol: protocol }, options));
82+
}
83+
84+
/*
85+
* Build client request
86+
*/
87+
var clientRequest = h.__proto__.request(options, redirectCallback(reqUrl, redirect));
88+
89+
// Save user's clientRequest so we can emit errors later
90+
if (!redirect.clientRequest) redirect.clientRequest = clientRequest;
91+
92+
/**
93+
* ClientRequest callback for redirects
94+
*/
95+
function redirectCallback (reqUrl, redirect) {
96+
return function (res) {
97+
// status must be 300-399 for redirects
98+
if (res.statusCode < 300 || res.statusCode > 399) {
99+
return redirect.userCallback(res);
100+
}
101+
102+
// no `Location:` header => nowhere to redirect
103+
if (!('location' in res.headers)) {
104+
return redirect.userCallback(res);
105+
}
106+
107+
// we are going to follow the redirect, but in node 0.10 we must first attach a data listener
108+
// to consume the stream and send the 'end' event
109+
res.on('data', function() {});
110+
111+
// save the original clientRequest to our redirectOptions so we can emit errors later
112+
113+
// need to use url.resolve() in case location is a relative URL
114+
var redirectUrl = url.resolve(reqUrl, res.headers['location']);
115+
// we need to call the right api (http vs https) depending on protocol
116+
var proto = url.parse(redirectUrl).protocol;
117+
proto = proto.substr(0, proto.length - 1);
118+
119+
// Make a new option object for next request from old options object
120+
// Break url in parts
121+
var searchname = url.parse(redirectUrl).search;
122+
var hostname = url.parse(redirectUrl).hostname;
123+
var pathname = url.parse(redirectUrl).pathname;
124+
125+
var redirectOptions = options;
126+
redirectOptions.reqUrl = redirectUrl;
127+
redirectOptions.hostname = hostname;
128+
redirectOptions.path = pathname + searchname;
129+
130+
var out = module.exports[proto].get(redirectOptions, redirectCallback(reqUrl, redirect), redirect);
131+
132+
// bubble errors that occur on the redirect back up to the initiating client request
133+
// object, otherwise they wind up killing the process.
134+
out.on("error", function(err) { clientRequest.emit("error", err) });
135+
136+
return out;
137+
};
138+
}
139+
140+
return clientRequest;
141+
}
142+
}(h);
143+
144+
// see https://github.com/joyent/node/blob/master/lib/http.js#L1623
145+
h.get = function (h) {
146+
return function (options, cb, redirectOptions) {
147+
var req = h.request(options, cb, redirectOptions);
148+
req.end();
149+
return req;
150+
};
151+
}(h);
152+
}

package.json

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "closurecompiler",
3-
"version": "1.3.1",
3+
"version": "1.3.2",
44
"description": "ClosureCompiler.js: Closure Compiler for node.js. The all-round carefree package.",
55
"author": "Daniel Wirtz <[email protected]>",
66
"contributors": [
@@ -19,9 +19,8 @@
1919
},
2020
"keywords": ["closure compiler", "closure", "compiler", "util", "utility"],
2121
"dependencies": {
22-
"tar": "*",
23-
"closurecompiler-externs": "*",
24-
"follow-redirects": "0.0.3"
22+
"tar": "0.1.20",
23+
"closurecompiler-externs": "*"
2524
},
2625
"license": "Apache License, Version 2.0",
2726
"engines": {

scripts/configure.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ function download(downloadUrl, filename, callback, ondata) {
155155
var url = require("url").parse(downloadUrl);
156156
var out = require("fs").createWriteStream(filename, { flags: 'w', encoding: null, mode: 0666 });
157157
var bytes = 0, total = -1;
158-
var req = require("follow-redirects").http.request({
158+
var req = require(path.join(__dirname, "..", "lib", "follow-redirects.js")).http.request({
159159
"hostname": url["host"],
160160
"method": "GET",
161161
"path": url["path"],

0 commit comments

Comments
 (0)