@@ -12,8 +12,8 @@ function printProgress (count, total) {
1212// Function to check whether new data should be retrieved.
1313function shouldFetch ( repository ) {
1414 let retrieve = false ;
15- if ( repository . url . includes ( "github.com" ) ) {
16- if ( queryCount < maxQueryCount ) {
15+ if ( repository . url . includes ( "github.com" ) && maxQueryCount > 0 ) {
16+ if ( queryCount < maxQueryCount || process . env . GITHUB_TOKEN ) {
1717 retrieve = true ;
1818 }
1919 }
@@ -75,6 +75,11 @@ async function updateData () {
7575
7676 sortModuleListByLastUpdate ( previousData , moduleList ) ;
7777
78+ const headers = { } ;
79+ if ( process . env . GITHUB_TOKEN ) {
80+ headers . Authorization = `Bearer ${ process . env . GITHUB_TOKEN } ` ;
81+ }
82+
7883 for ( const module of moduleList ) {
7984 const repositoryId = module . id ;
8085 const repositoryApiUrl = `https://api.github.com/repos/${ repositoryId } ` ;
@@ -85,12 +90,12 @@ async function updateData () {
8590
8691 if ( shouldFetchData ) {
8792 printProgress ( moduleCount , moduleListLength ) ;
88- const response = await fetch ( repositoryApiUrl ) ;
93+ const response = await fetch ( repositoryApiUrl , { headers } ) ;
8994 const data = await response . json ( ) ;
9095 queryCount += 1 ;
9196
9297 const branchUrl = `https://api.github.com/repos/${ repositoryId } /commits/${ data . default_branch } ` ;
93- const branchResponse = await fetch ( branchUrl ) ;
98+ const branchResponse = await fetch ( branchUrl , { headers } ) ;
9499 const branchData = await branchResponse . json ( ) ;
95100 queryCount += 1 ;
96101
0 commit comments