fix: align asset-manifest generator output with prettier config

The generator was using JSON.stringify which outputs double quotes, but our prettier config requires single quotes and trailing commas. This caused lint-staged to reformat the file during pre-commit, resulting in empty commit errors.
This commit is contained in:
plebeius
2025-11-02 18:40:15 +01:00
parent ac19034ac4
commit 4fd9a9c1a9
+9 -3
View File
@@ -18,14 +18,20 @@ const notFoundImages = readdirSync(notFoundDir)
.filter((file) => /^not-found-.*\.(jpg|jpeg|gif|png)$/i.test(file))
.map((file) => `assets/not-found/${file}`);
// Generate TypeScript file
// Generate TypeScript file with proper formatting (matches prettier config)
const formatArray = (arr) => {
if (arr.length === 0) return '[]';
if (arr.length === 1) return `['${arr[0]}']`;
return '[\n ' + arr.map((item) => `'${item}',`).join('\n ') + '\n]';
};
const output = `// Auto-generated file - do not edit manually
// Run 'node scripts/generate-asset-manifest.js' to regenerate
// This file is generated from public/assets/ directory
export const BANNERS = ${JSON.stringify(banners, null, 2)} as const;
export const BANNERS = ${formatArray(banners)} as const;
export const NOT_FOUND_IMAGES = ${JSON.stringify(notFoundImages, null, 2)} as const;
export const NOT_FOUND_IMAGES = ${formatArray(notFoundImages)} as const;
`;
// Ensure directory exists