feat: Add custom chapter transformation for Lily on the Valley source (#1719) (#1910)

This commit is contained in:
Justin COLLON
2025-12-24 13:21:54 +01:00
committed by GitHub
parent 2443d8f7fc
commit fef50e7b62
7 changed files with 70 additions and 4 deletions
+10 -2
View File
@@ -1,4 +1,4 @@
import { readFileSync } from 'fs';
import { existsSync, readFileSync } from 'fs';
import { fileURLToPath } from 'url';
import { dirname, join } from 'path';
@@ -20,8 +20,16 @@ const generator = function generator(source) {
encoding: 'utf-8',
});
const chapterTransformJsOrPath = source.options?.customJs?.chapterTransform;
const chapterTransformPath = chapterTransformJsOrPath
? join(folder, chapterTransformJsOrPath)
: '';
const chapterTransformJs = existsSync(chapterTransformPath)
? readFileSync(chapterTransformPath, { encoding: 'utf-8' })
: chapterTransformJsOrPath;
const pluginScript = `
${readNovelFullTemplate}
${readNovelFullTemplate.replace('// chapterTransformJs HERE', chapterTransformJs || '')}
const plugin = new FictioneerPlugin(${JSON.stringify(source)});
export default plugin;
`.trim();