fix: mod import validation
This commit is contained in:
+7
-4
@@ -49,13 +49,16 @@ export class TTSManager {
|
||||
if (!isModule(filePath)) return;
|
||||
|
||||
const modRaw = await import(`file://${filePath}`);
|
||||
|
||||
if (!modRaw || !modRaw.default) {
|
||||
this.log.warning('Invalid module format in %s', filePath);
|
||||
if (!modRaw) {
|
||||
this.log.warning('Mod import failed for %s', filePath);
|
||||
return;
|
||||
}
|
||||
|
||||
const mod = modRaw.default as TTSModule;
|
||||
const mod = (modRaw.default?.default || modRaw.default || modRaw) as TTSModule;
|
||||
if (!mod.name || typeof mod.generate !== 'function') {
|
||||
this.log.warning('Invalid module format in %s', filePath);
|
||||
return;
|
||||
}
|
||||
|
||||
this.log.verbose(`Loaded TTS mode: ${mod.name}`);
|
||||
this.modules.push(mod);
|
||||
|
||||
Reference in New Issue
Block a user