Delete existing attachments
This commit is contained in:
1 parent
3b5d7a9520
commit
8f722276f3
1 file changed
+17
@@ -33,6 +33,21 @@ This page was automatically generated on ${formattedDate}.
|
||||
fs.writeFileSync(markdownFile, markdownContent);
|
||||
}
|
||||
|
||||
async function deleteExistingAttachments() {
|
||||
try {
|
||||
const files = fs.readdirSync(attachmentDestination);
|
||||
|
||||
for (const file of files) {
|
||||
if (path.extname(file) === '.png') {
|
||||
fs.unlinkSync(path.join(attachmentDestination, file));
|
||||
console.log(`Deleted ${file}`);
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
}
|
||||
}
|
||||
|
||||
const config = getEnvVars(['EMAIL', 'EMAIL_APP_PASSWORD']);
|
||||
|
||||
const imap = new Imap({
|
||||
@@ -111,6 +126,8 @@ imap.once('ready', async () => {
|
||||
const yesterday = new Date(now - 24 * 60 * 60 * 1000);
|
||||
const yesterdayString = yesterday.toISOString().slice(0, 19).replace('T', ' ');
|
||||
|
||||
deleteExistingAttachments();
|
||||
|
||||
const images = []
|
||||
images.push({
|
||||
title: 'Channel Health',
|
||||
|
||||
Reference in new issue
Block a user