--- /dev/null
+'use strict';
+
+var ghRelease = require('./github.js');
+
+/**
+ * Gets the releases for 'ripgrep'. This function could be trimmed down and made
+ * for use with any github release.
+ *
+ * @param request
+ * @param {string} owner
+ * @param {string} repo
+ * @returns {PromiseLike<any> | Promise<any>}
+ */
+function getAllReleases(request, owner, repo, baseurl) {
+ if (!baseurl) {
+ return Promise.reject('missing baseurl');
+ }
+ return ghRelease(request, owner, repo, baseurl + '/api/v1').then(function (all) {
+ return all;
+ });
+}
+
+module.exports = getAllReleases;
+
+if (module === require.main) {
+ getAllReleases(require('@root/request'), 'root', 'serviceman', 'https://git.rootprojects.org').then(
+ function (all) {
+ console.log(JSON.stringify(all, null, 2));
+ }
+ );
+}
* @param {string} repo
* @returns {PromiseLike<any> | Promise<any>}
*/
-function getAllReleases(request, owner = 'BurntSushi', repo = 'ripgrep') {
+function getAllReleases(request, owner, repo, baseurl = 'https://api.github.com') {
if (!owner) {
return Promise.reject('missing owner for repo');
}
return Promise.reject('missing repo name');
}
return request({
- url: `https://api.github.com/repos/${owner}/${repo}/releases`,
+ url: `${baseurl}/repos/${owner}/${repo}/releases`,
json: true
}).then((resp) => {
const gHubResp = resp.body;