From ff032969a83c33219f18a7db3a03f6825f4615c9 Mon Sep 17 00:00:00 2001 From: David Recuenco Date: Wed, 20 Mar 2019 13:47:40 +0100 Subject: [PATCH] ALLOW download non .tar.gz releases --- src/index.js | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/index.js b/src/index.js index c342ce3..3cec4cf 100644 --- a/src/index.js +++ b/src/index.js @@ -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); }); @@ -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); + } }); }