Skip to content

Commit eaf2bcf

Browse files
committed
finally, cache hits!
1 parent 54fd866 commit eaf2bcf

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

scripts/generate-md-exports.mjs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ function taskFinishHandler(data) {
2828
console.log(
2929
`💰 Worker[${data.id}]: Cache hits: ${data.cacheHits} (${Math.round((data.cacheHits / data.success) * 100)}%)`
3030
);
31-
console.log(`✅ Worker[${data.id}]: ${data.success} files successfully.`);
31+
console.log(`✅ Worker[${data.id}]: converted ${data.success} files successfully.`);
3232
return false;
3333
}
3434
console.error(`❌ Worker[${data.id}]: ${data.failedTasks.length} files failed:`);
@@ -132,7 +132,10 @@ async function createWork() {
132132
const md5 = data => createHash('md5').update(data).digest('hex');
133133

134134
async function genMDFromHTML(source, target, {cacheDir, noCache}) {
135-
const text = await readFile(source, {encoding: 'utf8'});
135+
const text = (await readFile(source, {encoding: 'utf8'}))
136+
// Remove all script tags, as they are not needed in markdown
137+
// and they are not stable across builds, causing cache misses
138+
.replace(/<script[^>]*>[\s\S]*?<\/script>/g, '');
136139
const hash = md5(text);
137140
const cacheFile = path.join(cacheDir, hash);
138141
if (!noCache) {

0 commit comments

Comments
 (0)