async function grabBundleName() {
const files = await fs.readdir(directory);
const bundleFile = files.find((file) => file.startsWith('bundle-'));
return bundleFile;
}
async function buildHTML() {
const bundleName = await grabBundleName();
fs.readFile('templates/index-template.txt', 'utf8', function (err, data) {
if (err) {
return console.log(err);
}
const result = data.replace(/\[BUNDLE-NAME\]/g, bundleName);
fs.writeFile(`docs/index.html`, result, 'utf8', function (err) {
if (err) return console.log(err);
});
});
}