hotfix for github release API rate limit token
authorAJ ONeal <coolaj86@gmail.com>
Thu, 30 Jul 2020 06:35:34 +0000 (00:35 -0600)
committerAJ ONeal <coolaj86@gmail.com>
Thu, 30 Jul 2020 06:35:34 +0000 (00:35 -0600)
.gitignore
_common/github.js
package-lock.json
package.json

index 78216019d7e5c1a649a7668df9ddfe07545c194e..a1144c9c2c891e39a08efea95799daa8fba3ea5a 100644 (file)
@@ -1,3 +1,4 @@
+.env
 node_modules
 install-*.sh
 install-*.bat
index 442b16b0b82534fc7aea8399e3718d388f8641c5..aa98074ccfc9ed2fc8af7d5e6c13e4f75badded7 100644 (file)
@@ -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: [],
index 69f044af073f3c20588248cc1f3a8188cac8d79e..304b4e4568c31586723d186c3b7d2d0803e00cf1 100644 (file)
@@ -9,6 +9,11 @@
       "resolved": "https://registry.npmjs.org/@root/request/-/request-1.6.1.tgz",
       "integrity": "sha512-8wrWyeBLRp7T8J36GkT3RODJ6zYmL0/maWlAUD5LOXT28D3TDquUepyYDKYANNA3Gc8R5ZCgf+AXvSTYpJEWwQ=="
     },
+    "dotenv": {
+      "version": "8.2.0",
+      "resolved": "https://registry.npmjs.org/dotenv/-/dotenv-8.2.0.tgz",
+      "integrity": "sha512-8sJ78ElpbDJBHNeBzUbUVLsqKdccaa/BXF1uPTw3GrvQTBgrQrtObr2mUrE38vzYd8cEv+m/JBfDLioYcfXoaw=="
+    },
     "marked": {
       "version": "1.1.0",
       "resolved": "https://registry.npmjs.org/marked/-/marked-1.1.0.tgz",
index 105bbe416efbfdb273b1dae20f4253213f8b9744..a6961af6892e747123ac9e2d155ea6bb44366f63 100644 (file)
@@ -24,6 +24,7 @@
   "homepage": "https://github.com/webinstall/packages#readme",
   "dependencies": {
     "@root/request": "^1.6.1",
+    "dotenv": "^8.2.0",
     "shmatter": "^1.0.1"
   }
 }