-
-
Notifications
You must be signed in to change notification settings - Fork 212
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #64 from lgeiger/download-node
Use Node to download zeromq vs. wget
- Loading branch information
Showing
3 changed files
with
23 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
var https = require('https'); | ||
var fs = require('fs'); | ||
var url = require('url'); | ||
|
||
var TAR_URL = 'https://github.com/' + process.env.ZMQ_REPO + '/releases/download/v' + process.env.ZMQ + '/zeromq-' + process.env.ZMQ + '.tar.gz'; | ||
var FILE_NAME = 'zeromq-' + process.env.ZMQ + '.tar.gz'; | ||
|
||
function writeToFile(response) { | ||
response.pipe(fs.createWriteStream(FILE_NAME)); | ||
} | ||
|
||
https.get(TAR_URL, function(response) { | ||
if (response.statusCode > 300 && response.statusCode < 400 && response.headers.location) { | ||
if (url.parse(response.headers.location).hostname) { | ||
https.get(response.headers.location, writeToFile); | ||
} else { | ||
https.get(url.resolve(url.parse(TAR_URL).hostname, response.headers.location), writeToFile); | ||
} | ||
} else { | ||
writeToFile(response); | ||
} | ||
}); |