Standardize blog source formatting with Prettier

This commit is contained in:
biss committed 2026-12-01 18:47:17 +08:00
1 parent c14493c00f
commit 7809bf12c7
64 files changed
+2239 -1382

No files matched your search

+3 -1
View File
@@ -99,7 +99,9 @@ async function main() {
if (existing) {
if (existingFiles.has(existing)) {
throw new Error(`Duplicate abbrlink "${existing}" in ${relative(process.cwd(), existingFiles.get(existing))} and ${relative(process.cwd(), file)}`);
throw new Error(
`Duplicate abbrlink "${existing}" in ${relative(process.cwd(), existingFiles.get(existing))} and ${relative(process.cwd(), file)}`,
);
}
existingFiles.set(existing, file);
usedAbbrlinks.add(existing);
+10 -5
View File
@@ -11,10 +11,12 @@ hash.update('\0');
async function collect(directory) {
const entries = await readdir(directory, { withFileTypes: true });
const files = await Promise.all(entries.map((entry) => {
const path = join(directory, entry.name);
return entry.isDirectory() ? collect(path) : [path];
}));
const files = await Promise.all(
entries.map((entry) => {
const path = join(directory, entry.name);
return entry.isDirectory() ? collect(path) : [path];
}),
);
return files.flat();
}
@@ -26,6 +28,9 @@ for (const path of files) {
hash.update('\0');
}
const versioned = source.replace(/^const CACHE_VERSION = '[^']+';/m, `const CACHE_VERSION = '${hash.digest('hex').slice(0, 16)}';`);
const versioned = source.replace(
/^const CACHE_VERSION = '[^']+';/m,
`const CACHE_VERSION = '${hash.digest('hex').slice(0, 16)}';`,
);
if (versioned === source) throw new Error('Service worker cache version was not found');
await writeFile(worker, versioned);