X-Git-Url: https://git.josue.xyz/?a=blobdiff_plain;f=_common%2Fgithub.js;h=aa98074ccfc9ed2fc8af7d5e6c13e4f75badded7;hb=3da9f3e1c5dfe814dcacb165db7bd164c1ea64ff;hp=7b62ea3a04cc467b97de9ca50087fec201243c3b;hpb=fa2dcece4ca1b421fc427117de11778c60804538;p=webi-installers%2F.git diff --git a/_common/github.js b/_common/github.js index 7b62ea3..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: [], @@ -38,7 +50,7 @@ function getAllReleases( all.releases.push({ name: name, version: release['tag_name'], // TODO tags aren't always semver / sensical - lts: /\b(lts)\b/.test(release['tag_name']), + lts: /(\b|_)(lts)(\b|_)/.test(release['tag_name']), channel: !release['prerelease'] ? 'stable' : 'beta', date: (release['published_at'] || '').replace(/T.*/, ''), os: '', // will be guessed by download filename @@ -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)); } ); }