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