@@ -15,6 +15,14 @@ export { Fellow, PromisePool, Errlop }
1515import { env } from 'node:process'
1616const envCredentials = env as GitHubCredentials
1717
18+ export function shouldAutomate ( value : any ) : boolean {
19+ return value == null || value === true
20+ }
21+
22+ export function getFallback ( value : any , fallback : any ) {
23+ return shouldAutomate ( value ) ? fallback : value
24+ }
25+
1826// ====================================
1927// Our Types
2028
@@ -513,8 +521,13 @@ export async function getBackersFromThanksDev(
513521 username : string ,
514522 opts : BackersQueryOptions = { } ,
515523) : Promise < ThanksDevBackers > {
516- const sponsorCentsThreshold = opts . sponsorCentsThreshold ?? 100
517- const donorCentsThreshold = opts . donorCentsThreshold ?? 100
524+ // defaults
525+ const sponsorCentsThreshold : number = getFallback (
526+ opts . sponsorCentsThreshold ,
527+ 100 ,
528+ )
529+ const donorCentsThreshold : number = getFallback ( opts . donorCentsThreshold , 100 )
530+ // prepare
518531 let sponsors : Array < ThanksDevDonor > = [ ] ,
519532 donors : Array < ThanksDevDonor > = [ ]
520533 // monthly
@@ -618,8 +631,16 @@ export async function getBackersFromOpenCollective(
618631 opts : BackersQueryOptions = { } ,
619632) : Promise < OpenCollectiveBackers > {
620633 try {
621- const sponsorCentsThreshold = opts . sponsorCentsThreshold ?? 100
622- const donorCentsThreshold = opts . donorCentsThreshold ?? 100
634+ // defaults
635+ const sponsorCentsThreshold : number = getFallback (
636+ opts . sponsorCentsThreshold ,
637+ 100 ,
638+ )
639+ const donorCentsThreshold : number = getFallback (
640+ opts . donorCentsThreshold ,
641+ 100 ,
642+ )
643+ // fetch
623644 const url = `https://opencollective.com/${ username } /members.json`
624645 const resp = await fetch ( url , { } )
625646 const profiles : OpenCollectiveResponse = await resp . json ( )
@@ -1899,11 +1920,15 @@ export async function getBackers(
18991920 { }
19001921 try {
19011922 // if auto-detect package data, fetch from slug if not offline
1902- if ( githubSlug && opts . packageData !== false && opts . offline !== true ) {
1923+ if (
1924+ githubSlug &&
1925+ shouldAutomate ( opts . packageData ) &&
1926+ opts . offline !== true
1927+ ) {
19031928 packageData = await getPackageData ( githubSlug , { } )
19041929 }
19051930 // if auto-detect slug, fetch from package data
1906- if ( opts . githubSlug !== false && packageData ) {
1931+ if ( shouldAutomate ( opts . githubSlug ) && packageData ) {
19071932 githubSlug = getGitHubSlugFromPackageData ( packageData ) || ''
19081933 }
19091934
0 commit comments