From e013621244332f1f36ac2b70ade62952e8d1d2be Mon Sep 17 00:00:00 2001 From: Miyo <135030944+yuri-kiss@users.noreply.github.com> Date: Fri, 2 Aug 2024 03:11:32 -0400 Subject: [PATCH] Update index.xml to files.xml --- build/index.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/build/index.js b/build/index.js index 689480c..a29339e 100644 --- a/build/index.js +++ b/build/index.js @@ -2,6 +2,9 @@ const { XMLDoc, XMLNode } = require('./xml.js'); const fs = require('fs').promises; const path = require('path'); +const file = 'files.xml'; +const filePath = `./site/${file}`; + async function walk(dir) { let files = await fs.readdir(dir); files = await Promise.all(files.map(async file => { @@ -23,11 +26,11 @@ walk('./site').then(async (files) => { map.appendChild(node); } try { - await (fs.stat('./site/index.xml').catch((err) => {}).then((stats) => { - fs.unlink('./site/index.xml').catch((err) => {}).then(() => console.log('Deleted existing map succesfully.')).finally(); + await (fs.stat(filePath).catch((err) => {}).then((stats) => { + fs.unlink(filePath).catch((err) => {}).then(() => console.log('Deleted existing map succesfully.')).finally(); })); } catch { } finally { - fs.writeFile('./site/index.xml', map.toString(), 'utf8').catch((err) => console.error('Failed to write index.xml\n', err)).then(() => console.log('Wrote index.xml')); + fs.writeFile(filePath, map.toString(), 'utf8').catch((err) => console.error(`Failed to write ${file}\n'` err)).then(() => console.log(`Wrote ${file}`)); } });