mirror of
https://github.com/Kir-Antipov/mc-publish.git
synced 2024-11-25 09:51:01 -05:00
Made factory for the different publishers
This commit is contained in:
parent
22df1b7930
commit
f73c20d76f
1 changed files with 24 additions and 0 deletions
24
src/publishing/publisher-factory.ts
Normal file
24
src/publishing/publisher-factory.ts
Normal file
|
@ -0,0 +1,24 @@
|
|||
import Publisher from "./publisher";
|
||||
import PublisherTarget from "./publisher-target";
|
||||
import GitHubPublisher from "./github-publisher";
|
||||
import ModrinthPublisher from "./modrinth-publisher";
|
||||
import CurseForgePublisher from "./curseforge-publisher";
|
||||
import Logger from "../utils/logger";
|
||||
|
||||
export default class PublisherFactory {
|
||||
public create(target: PublisherTarget, options: Record<string, unknown>, logger?: Logger): Publisher<unknown> {
|
||||
switch(target) {
|
||||
case PublisherTarget.GitHub:
|
||||
return new GitHubPublisher(<any>options, logger);
|
||||
|
||||
case PublisherTarget.Modrinth:
|
||||
return new ModrinthPublisher(<any>options, logger);
|
||||
|
||||
case PublisherTarget.CurseForge:
|
||||
return new CurseForgePublisher(<any>options, logger);
|
||||
|
||||
default:
|
||||
throw new Error(`Unknown target "${PublisherTarget.toString(target)}"`);
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue