Skip to content

Commit c0dec46

Browse files
ci: format fetch-spec-types output with prettier
The nightly update-spec-types workflow is failing because lefthook's pre-push hook (added in #1003) runs `pnpm run lint:all`, which rejects the freshly-fetched spec.types.ts for not matching prettier style. Format the output via prettier's Node API using the project config before writing it to disk. This also reduces nightly PR diffs to only semantic changes, not formatting noise.
1 parent 379392d commit c0dec46

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

scripts/fetch-spec-types.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { writeFileSync } from 'node:fs';
22
import { dirname, join } from 'node:path';
33
import { fileURLToPath } from 'node:url';
4+
import * as prettier from 'prettier';
45

56
const __filename = fileURLToPath(import.meta.url);
67
const __dirname = dirname(__filename);
@@ -72,9 +73,12 @@ async function main() {
7273
// Combine header and content
7374
const fullContent = header + specContent;
7475

75-
// Write to file
76+
// Format with prettier using the project's config so the output passes lint
7677
const outputPath = join(PROJECT_ROOT, 'packages', 'core', 'src', 'types', 'spec.types.ts');
77-
writeFileSync(outputPath, fullContent, 'utf-8');
78+
const prettierConfig = await prettier.resolveConfig(outputPath);
79+
const formatted = await prettier.format(fullContent, { ...prettierConfig, filepath: outputPath });
80+
81+
writeFileSync(outputPath, formatted, 'utf-8');
7882

7983
console.log('Successfully updated packages/core/src/types/spec.types.ts');
8084
} catch (error) {

0 commit comments

Comments
 (0)