Skip to content

Commit

Permalink
remove 'superagent' dependency, use node https. fixes getgauge#1719
Browse files Browse the repository at this point in the history
Signed-off-by: sriv <srikanth.ddit@gmail.com>
  • Loading branch information
sriv committed Aug 26, 2020
1 parent 59d0a4b commit 66acf91
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 131 deletions.
Empty file removed build/npm/bin/gauge
Empty file.
124 changes: 0 additions & 124 deletions build/npm/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion build/npm/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
"sinon": "^6.2.0"
},
"dependencies": {
"superagent": "^5.2.2",
"unzipper": "^0.9.3"
}
}
20 changes: 14 additions & 6 deletions build/npm/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,25 +5,33 @@
const install = require("./install"),
path = require("path"),
unzip = require('unzipper'),
request = require('superagent'),
https = require('https'),
packageJsonPath = path.join(__dirname, "..", "package.json"),
binPath = "./bin";

var downloadFollowingRedirect = function(url, resolve, reject) {
https.get(url, { headers: { 'accept-encoding': 'gzip,deflate' } }, res => {
if (res.statusCode >= 300 && res.statusCode < 400) {
downloadFollowingRedirect(res.headers.location, reject, resolve);
} else {
res.pipe(unzip.Extract({ path: path.normalize(binPath) })).on('error', reject).on('end', resolve);
}
});
};

var downloadAndExtract = function(version) {
console.log(`Fetching download url for Gauge version ${version}`);
let url = install.getBinaryUrl(version);
console.log(`Downloading ${url} to ${binPath}`);
return new Promise((resolve, reject) => {
try {
request.get(url).pipe(unzip.Extract({ path: path.normalize(binPath) }));
resolve();
downloadFollowingRedirect(url, resolve, reject);
} catch (error) {
reject(error);
}
})
}
};

install.getVersion(packageJsonPath)
.then((v) => downloadAndExtract(v.split('-')[0]))
.catch((e) => console.error(e));
.then((v) => downloadAndExtract(v.split('-')[0]))
.catch((e) => console.error(e));

0 comments on commit 66acf91

Please sign in to comment.