File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -12,15 +12,24 @@ import { GitHubRepository } from '../github/githubRepository';
1212
1313export async function getGitHubFileContent ( gitHubRepository : GitHubRepository , fileName : string , ref : string ) : Promise < Uint8Array > {
1414 const { octokit, remote } = await gitHubRepository . ensure ( ) ;
15- let fileContent : { data : { content : string ; encoding : string ; sha : string } } = ( await octokit . call ( octokit . api . repos . getContent ,
16- {
17- owner : remote . owner ,
18- repo : remote . repositoryName ,
19- path : fileName ,
20- ref,
21- } ,
22- ) ) as any ;
23- let contents = fileContent . data . content ?? '' ;
15+ let contents : string = '' ;
16+ let fileContent : { data : { content : string ; encoding : string ; sha : string } } ;
17+ try {
18+ fileContent = ( await octokit . call ( octokit . api . repos . getContent ,
19+ {
20+ owner : remote . owner ,
21+ repo : remote . repositoryName ,
22+ path : fileName ,
23+ ref,
24+ } ,
25+ ) ) as any ;
26+ contents = fileContent . data . content ?? '' ;
27+ } catch ( e ) {
28+ if ( e . status === 404 ) {
29+ return new Uint8Array ( 0 ) ;
30+ }
31+ throw e ;
32+ }
2433
2534 // Empty contents and 'none' encoding indcates that the file has been truncated and we should get the blob.
2635 if ( contents === '' && fileContent . data . encoding === 'none' ) {
You can’t perform that action at this time.
0 commit comments