From 977a7f82acf2a5d48712505a105f995b7dec8a3b Mon Sep 17 00:00:00 2001 From: OJII3 <84656786+OJII3@users.noreply.github.com> Date: Fri, 17 Nov 2023 15:51:26 +0900 Subject: [PATCH] [fix]: type export and multi category handling --- lib/type.d.ts | 2 +- src/modulegen.ts | 17 +++++++++++------ 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/lib/type.d.ts b/lib/type.d.ts index 033c706..e32cda7 100644 --- a/lib/type.d.ts +++ b/lib/type.d.ts @@ -1 +1 @@ -export { UserConfig, FieldConfig, DocumentConfig } from '../src/types'; +export { UserConfig, FieldConfig, CategoryConfig } from '../src/types'; diff --git a/src/modulegen.ts b/src/modulegen.ts index 1dac768..ba44931 100644 --- a/src/modulegen.ts +++ b/src/modulegen.ts @@ -55,12 +55,17 @@ export class ModuleGenerator { `Generated ${documentModules.length} modules for ${categoryConfig.documentCategory}`, ); - this.categoryModules = this.categoryModules.map((categoryModule) => { - return { - documentCategory: categoryModule.documentCategory, - documentModules: documentModules, - }; - }); + try { + this.categoryModules[ + this.categoryModules.findIndex((m) => { + m.documentCategory === categoryConfig.documentCategory; + }) + ].documentModules = documentModules; + } catch (e) { + console.log( + `Skipping ${categoryConfig.documentCategory} due to error: ${e.message}`, + ); + } } return this.categoryModules; }