Skip to content

Commit

Permalink
ALLOW download non .tar.gz releases
Browse files Browse the repository at this point in the history
  • Loading branch information
RecuencoJones committed Mar 20, 2019
1 parent ff6d922 commit ff03296
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,9 @@ function verifyAndPlaceBinary(binName, binPath, callback) {

// Move the binary file
fs.renameSync(path.join(binPath, binName), path.join(installationPath, binName));
fs.chmodSync(path.join(installationPath, binName), "755");

console.log("Placed binary on", path.join(installationPath, binName))

callback(null);
});
Expand Down Expand Up @@ -174,7 +177,16 @@ function install(callback) {
req.on('response', function(res) {
if (res.statusCode !== 200) return callback("Error downloading binary. HTTP Status Code: " + res.statusCode);

req.pipe(ungz).pipe(untar);
if (opts.url.endsWith('.tar.gz')) {
req.pipe(ungz).pipe(untar);
} else {
const stream = fs.createWriteStream(path.join(opts.binPath, opts.binName));

stream.on('close', verifyAndPlaceBinary.bind(null, opts.binName, opts.binPath, callback));
stream.on('error', callback);

req.pipe(stream);
}
});
}

Expand Down

0 comments on commit ff03296

Please sign in to comment.