From 4151c36500934e15498e7c5c9db3b2c8d9067b76 Mon Sep 17 00:00:00 2001 From: Kir_Antipov Date: Tue, 7 Dec 2021 21:42:49 +0300 Subject: [PATCH] Chained all known `ModMetadataReader`s --- src/metadata/mod-metadata-reader.ts | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/metadata/mod-metadata-reader.ts b/src/metadata/mod-metadata-reader.ts index b388dff..ff97f40 100644 --- a/src/metadata/mod-metadata-reader.ts +++ b/src/metadata/mod-metadata-reader.ts @@ -1,7 +1,22 @@ +import ModLoaderType from "./mod-loader-type"; import ModMetadata from "./mod-metadata"; +import ModMetadataReaderFactory from "./mod-metadata-reader-factory"; interface ModMetadataReader { readMetadata(modPath: string): Promise; } +namespace ModMetadataReader { + export async function readMetadata(modPath: string): Promise { + 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;