Skip to content

Commit fed3a62

Browse files
committed
fix(pipelines): add GitHub token for pkg:fetch-extra command
1 parent 609d3c3 commit fed3a62

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

app/jobs/fetchPackageExtra.js

+5-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
// Fetch package extra data
22

33
const axios = require("axios");
4+
const config = require("config");
45
const urljoin = require("url-join");
56
const packageExtra = require("../models/packageExtra");
67
const {
@@ -41,11 +42,12 @@ const fetchExtraData = async function(packageNames) {
4142
}
4243
// Fetch stars
4344
try {
45+
const headers = { Accept: "application/vnd.github.v3.json" };
46+
if (config.gitHub.token)
47+
headers.authorization = `Bearer ${config.gitHub.token}`;
4448
const resp = await axios.get(
4549
urljoin("https://api.github.com/repos/", pkg.repo),
46-
{
47-
headers: { Accept: "application/vnd.github.v3.json" }
48-
}
50+
{ headers }
4951
);
5052
const repoInfo = resp.data;
5153
let stars = 0;

0 commit comments

Comments
 (0)