( filename: string, owner: string, repo: string, env: Env, )
| 275 | * @param env - Environment for GitHub token |
| 276 | */ |
| 277 | export async function searchFileByName( |
| 278 | filename: string, |
| 279 | owner: string, |
| 280 | repo: string, |
| 281 | env: Env, |
| 282 | ): Promise<any> { |
| 283 | const searchUrl = `https://api.github.com/search/code?q=filename:${filename}+repo:${owner}/${repo}`; |
| 284 | const response = await githubApiRequest(searchUrl, {}, env); |
| 285 | |
| 286 | if (!response || !response.ok) { |
| 287 | console.warn( |
| 288 | `GitHub API filename search failed: ${response?.status} ${response?.statusText}`, |
| 289 | ); |
| 290 | return null; |
| 291 | } |
| 292 | |
| 293 | return response.json(); |
| 294 | } |
| 295 | |
| 296 | /** |
| 297 | * Fetch raw file content from GitHub |
no test coverage detected