in src/functions.ts [69:93]
export async function saveUpdatedMarkdown(
zennMetaData: Partial<ZennMetadata>,
changedMarkdowns: string[],
postPath: string = ""
) {
const savedPaths = new Array<string>();
for (const markdownPath of changedMarkdowns) {
const markdown = readFileSync(markdownPath);
info(`read ${markdownPath}`);
try {
const updatedMarkdown = await updateMarkdown(markdown, zennMetaData);
const savePath = markdownPath + postPath;
writeFileSync(savePath, updatedMarkdown);
savedPaths.push(savePath);
info(`saved ${savePath}`);
} catch (e) {
if (e instanceof NotEnoughPropertyError) {
info("this markdown is not Zenn article. Skipped.");
continue;
}
throw e;
}
}
return savedPaths;
}