cache list of generated filenames

Signed-off-by: Xe Iaso <me@xeiaso.net>
This commit is contained in:
Xe Iaso 2023-04-14 18:30:26 -04:00
parent 5f8c1a2fad
commit 4e0ce8b2fa

View File

@ -150,6 +150,10 @@ program
console.error(`plot summary does not exist in ${dir}, run genChapterScenes?`);
process.exit(1);
}
if (fileExists(`${dir}/fnames.json`)) {
console.error(`file name list already exists in ${dir}`);
process.exit(1);
}
await fs.mkdir(`${dir}/src`, { recursive: true });
@ -162,7 +166,9 @@ program
for (let [chNum, ch] of chapters.entries()) {
chNum = chNum + 1;
await fs.writeFile(`${dir}/src/ch-${chNum}-sc-00.md`, `# ${ch.title}\n\n`);
const fname = `ch-${chNum}-sc-00.md`;
fnames.push(fname);
await fs.writeFile(`${dir}/src/${fname}`, `# ${ch.title}\n\n`);
for (let [sceneNum, scene] of ch.sceneDescriptions.entries()) {
sceneNum = sceneNum + 1;
fnames.push(await book.writeChapterScene(dir, openai, summary, ch, chNum, sceneNum, scene));
@ -170,6 +176,7 @@ program
}
console.log(fnames);
await fs.writeFile(`${dir}/fnames.json`, JSON.stringify(fnames, undefined, " "));
});
program.parse();