Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

remove 'superagent' dependency, use node https. fixes #1719 #1727

Merged
merged 4 commits into from
Aug 28, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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));