-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Adding listGithubRepoContents()
to lib
#84
Conversation
Build failing due to third-party dep |
const error = e as GenericError; | ||
if (error?.response?.data?.message) { | ||
throwErrorWithMessage( | ||
`${i18nKey}.downloadGithubRepoContents.errors.fetchFail`, | ||
{ | ||
errorMessage: error.response.data.message, | ||
} | ||
); | ||
} else { | ||
throwError(error); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Throwing the error with message here based on the github error response for fetching. Using GenericError
as the type -- I'm not sure if it is preferred that I make a new type of Error - GithubErrorContext with the shape of the response to match. Above this function the downloadGithubRepoContents
method is using BaseError
as the type, but I would expect the response shape of the errors to be the same between these two. However, the error.error.message
property path doesn't exist on the fetch fail response from GH.
export async function listGithubRepoContents( | ||
repoPath: RepoPath, | ||
contentPath: string, | ||
fileFilter?: 'file' | 'dir' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Strictly typing the options here that are relevant to the response from fetching GitHub repo contents
# Conflicts: # lib/github.ts
Description and Context
In order to support an addition to the CLI for listing out available modules in a repo for this issue - I've created a generic function that is going accept a repo and content path, as well as an additional option for filtering by the type of the asset returned in the array (either a file or directory based on the GH response).
This is completely additive and shouldn't affect other functionality in the lib.