Skip to content

Commit 29aff8e

Browse files
committed
Add support for GitHub API tokens when fetching releases
Looks for GITHUB_USER and GITHUB_TOKEN env vars (cherry picked from commit cab1beb)
1 parent 21a4c30 commit 29aff8e

1 file changed

Lines changed: 8 additions & 2 deletions

File tree

lib/installHelpers.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -361,13 +361,19 @@ function checkLatestAdaptRepoVersion(repoName, versionLimit, callback) {
361361
var nextPage = `https://api.github.com/repos/${DEFAULT_GITHUB_ORG}/${repoName}/releases`;
362362

363363
var _getReleases = function(done) {
364-
request({
364+
const opts = {
365365
headers: {
366366
'User-Agent': DEFAULT_USER_AGENT
367367
},
368368
uri: nextPage,
369369
method: 'GET'
370-
}, done);
370+
};
371+
const { GITHUB_USER, GITHUB_TOKEN } = process.env;
372+
if(GITHUB_USER && GITHUB_TOKEN) {
373+
const authHash = Buffer.from(`${GITHUB_USER}:${GITHUB_TOKEN}`).toString('base64');
374+
opts.headers.Authorization = `Basic ${authHash}`;
375+
}
376+
request(opts, done);
371377
};
372378
var _requestHandler = function(error, response, body) {
373379
if(response) {

0 commit comments

Comments
 (0)