mirror of
https://github.com/Kir-Antipov/mc-publish.git
synced 2024-11-28 19:31:03 -05:00
Chained all known ModMetadataReader
s
This commit is contained in:
parent
0844ce3a92
commit
4151c36500
1 changed files with 15 additions and 0 deletions
|
@ -1,7 +1,22 @@
|
||||||
|
import ModLoaderType from "./mod-loader-type";
|
||||||
import ModMetadata from "./mod-metadata";
|
import ModMetadata from "./mod-metadata";
|
||||||
|
import ModMetadataReaderFactory from "./mod-metadata-reader-factory";
|
||||||
|
|
||||||
interface ModMetadataReader {
|
interface ModMetadataReader {
|
||||||
readMetadata(modPath: string): Promise<ModMetadata | null>;
|
readMetadata(modPath: string): Promise<ModMetadata | null>;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
namespace ModMetadataReader {
|
||||||
|
export async function readMetadata(modPath: string): Promise<ModMetadata | null> {
|
||||||
|
const factory = new ModMetadataReaderFactory();
|
||||||
|
for (const loaderType of ModLoaderType.getValues()) {
|
||||||
|
const metadata = await factory.create(loaderType).readMetadata(modPath).catch(_ => null);
|
||||||
|
if (metadata) {
|
||||||
|
return metadata;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
export default ModMetadataReader;
|
export default ModMetadataReader;
|
||||||
|
|
Loading…
Reference in a new issue