X-Git-Url: https://git.josue.xyz/?a=blobdiff_plain;f=_common%2Fgithub.js;h=aa98074ccfc9ed2fc8af7d5e6c13e4f75badded7;hb=aa61db993471a5ec35fadbc050126735b9fc200a;hp=ef3a64fa5222a423d1ebd998cccdaae1fb9e4fe5;hpb=9b6ad3123438f931b12aaf88041db55cafaf4f81;p=webi-installers%2F.git diff --git a/_common/github.js b/_common/github.js index ef3a64f..aa98074 100644 --- a/_common/github.js +++ b/_common/github.js @@ -1,5 +1,7 @@ 'use strict'; +require('dotenv').config(); + /** * Gets the releases for 'ripgrep'. This function could be trimmed down and made * for use with any github release. @@ -21,10 +23,20 @@ function getAllReleases( if (!repo) { return Promise.reject('missing repo name'); } - return request({ + + var req = { url: `${baseurl}/repos/${owner}/${repo}/releases`, json: true - }).then((resp) => { + }; + // TODO I really don't like global config, find a way to do better + if (process.env.GITHUB_USERNAME) { + req.auth = { + user: process.env.GITHUB_USERNAME, + pass: process.env.GITHUB_TOKEN + }; + } + + return request(req).then((resp) => { const gHubResp = resp.body; const all = { releases: [], @@ -58,7 +70,7 @@ module.exports = getAllReleases; if (module === require.main) { getAllReleases(require('@root/request'), 'BurntSushi', 'ripgrep').then( function (all) { - console.log(JSON.stringify(all, null, 2)); + console.info(JSON.stringify(all, null, 2)); } ); }