cache list of generated filenames
Signed-off-by: Xe Iaso <me@xeiaso.net>
This commit is contained in:
parent
5f8c1a2fad
commit
4e0ce8b2fa
9
index.ts
9
index.ts
@ -150,6 +150,10 @@ program
|
|||||||
console.error(`plot summary does not exist in ${dir}, run genChapterScenes?`);
|
console.error(`plot summary does not exist in ${dir}, run genChapterScenes?`);
|
||||||
process.exit(1);
|
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 });
|
await fs.mkdir(`${dir}/src`, { recursive: true });
|
||||||
|
|
||||||
@ -162,7 +166,9 @@ program
|
|||||||
|
|
||||||
for (let [chNum, ch] of chapters.entries()) {
|
for (let [chNum, ch] of chapters.entries()) {
|
||||||
chNum = chNum + 1;
|
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()) {
|
for (let [sceneNum, scene] of ch.sceneDescriptions.entries()) {
|
||||||
sceneNum = sceneNum + 1;
|
sceneNum = sceneNum + 1;
|
||||||
fnames.push(await book.writeChapterScene(dir, openai, summary, ch, chNum, sceneNum, scene));
|
fnames.push(await book.writeChapterScene(dir, openai, summary, ch, chNum, sceneNum, scene));
|
||||||
@ -170,6 +176,7 @@ program
|
|||||||
}
|
}
|
||||||
|
|
||||||
console.log(fnames);
|
console.log(fnames);
|
||||||
|
await fs.writeFile(`${dir}/fnames.json`, JSON.stringify(fnames, undefined, " "));
|
||||||
});
|
});
|
||||||
|
|
||||||
program.parse();
|
program.parse();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user