mirror of
https://github.com/Mintplex-Labs/anything-llm.git
synced 2025-03-13 05:32:24 +00:00
* chore: rename Github to GitHub Signed-off-by: Adam Setch <adam.setch@outlook.com> * chore: rename Github to GitHub Signed-off-by: Adam Setch <adam.setch@outlook.com> * Undo some code changes for references --------- Signed-off-by: Adam Setch <adam.setch@outlook.com> Co-authored-by: timothycarambat <rambat1010@gmail.com>
41 lines
1.5 KiB
JavaScript
41 lines
1.5 KiB
JavaScript
/**
|
|
* Dynamically load the correct repository loader from a specific platform
|
|
* by default will return GitHub.
|
|
* @param {('github'|'gitlab')} platform
|
|
* @returns {import("./GithubRepo/RepoLoader")|import("./GitlabRepo/RepoLoader")} the repo loader class for provider
|
|
*/
|
|
function resolveRepoLoader(platform = "github") {
|
|
switch (platform) {
|
|
case "github":
|
|
console.log(`Loading GitHub RepoLoader...`);
|
|
return require("./GithubRepo/RepoLoader");
|
|
case "gitlab":
|
|
console.log(`Loading GitLab RepoLoader...`);
|
|
return require("./GitlabRepo/RepoLoader");
|
|
default:
|
|
console.log(`Loading GitHub RepoLoader...`);
|
|
return require("./GithubRepo/RepoLoader");
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Dynamically load the correct repository loader function from a specific platform
|
|
* by default will return Github.
|
|
* @param {('github'|'gitlab')} platform
|
|
* @returns {import("./GithubRepo")['fetchGithubFile'] | import("./GitlabRepo")['fetchGitlabFile']} the repo loader class for provider
|
|
*/
|
|
function resolveRepoLoaderFunction(platform = "github") {
|
|
switch (platform) {
|
|
case "github":
|
|
console.log(`Loading GitHub loader function...`);
|
|
return require("./GithubRepo").loadGithubRepo;
|
|
case "gitlab":
|
|
console.log(`Loading GitLab loader function...`);
|
|
return require("./GitlabRepo").loadGitlabRepo;
|
|
default:
|
|
console.log(`Loading GitHub loader function...`);
|
|
return require("./GithubRepo").loadGithubRepo;
|
|
}
|
|
}
|
|
|
|
module.exports = { resolveRepoLoader, resolveRepoLoaderFunction };
|