import fs from 'node:fs/promises'; import path from 'node:path'; var args = process.argv.slice(2); const linkRegex = new RegExp(/ x.includes('.html')); console.log(`Found ${files.length} files with .html extensions`); let modifications = 0; await Promise.all(files.map(async (x) => { const filePath = path.resolve(path.join(buildDir, x)); //console.log(`Replacing at ${filePath}`); await fs.writeFile(filePath, (await fs.readFile(filePath)).toString().replace(linkRegex, (match, capture, offset, string, groups) => { // this may not be fully accurate since we're mutating concurrently/async // but its a good enough signal for logging to tell if replacements happened modifications++; return match.replace(capture, replacement); })); })); console.log(`Done with ${modifications} replacements`); }());