Skip to content

Commit

Permalink
Merge pull request #81 from HubSpot/br-fix-github-fetch-content
Browse files Browse the repository at this point in the history
Fix github download logic to accept arrays
  • Loading branch information
brandenrodgers authored Jan 17, 2024
2 parents 1ac7bce + 2c5d135 commit 0bd2891
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
6 changes: 5 additions & 1 deletion lib/github.ts
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,11 @@ async function fetchGitHubRepoContentFromDownloadUrl(
downloadUrl: string
): Promise<void> {
const resp = await fetchRepoFileByDownloadUrl(downloadUrl);
fs.writeFileSync(dest, resp.data, 'utf8');
const fileContents =
typeof resp.data === 'string'
? resp.data
: JSON.stringify(resp.data, null, 2);
fs.outputFileSync(dest, fileContents, 'utf8');
}

// Writes files from a public repository to the destination folder
Expand Down
4 changes: 2 additions & 2 deletions types/Utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@ type Join<K, P> = K extends string | number
export type Leaves<T> = [10] extends [never]
? never
: T extends object
? { [K in keyof T]-?: Join<K, Leaves<T[K]>> }[keyof T]
: '';
? { [K in keyof T]-?: Join<K, Leaves<T[K]>> }[keyof T]
: '';

0 comments on commit 0bd2891

Please sign in to comment.