Skip to content

Commit f9a3b3d

Browse files
branchseerclaude
andcommitted
fix: run prettier on modified vite config to avoid format check failures
Projects like vue-mini run `vp run format` which checks Prettier formatting. The injected cacheScripts config must be formatted. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 7e3ab11 commit f9a3b3d

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

ecosystem-ci/patch-project.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,18 +50,26 @@ execSync(`${cli} migrate --no-agent --no-interactive`, {
5050
// Migration may create vite.config.ts, preserve an existing .ts/.js, or create none at all.
5151
const tsPath = join(cwd, 'vite.config.ts');
5252
const jsPath = join(cwd, 'vite.config.js');
53+
let viteConfigPath: string;
5354
if (existsSync(tsPath) || existsSync(jsPath)) {
54-
const viteConfigPath = existsSync(tsPath) ? tsPath : jsPath;
55+
viteConfigPath = existsSync(tsPath) ? tsPath : jsPath;
5556
const viteConfig = await readFile(viteConfigPath, 'utf-8');
5657
await writeFile(
5758
viteConfigPath,
5859
viteConfig.replace('defineConfig({', 'defineConfig({\n run: { cacheScripts: true },'),
5960
'utf-8',
6061
);
6162
} else {
63+
viteConfigPath = tsPath;
6264
await writeFile(
6365
tsPath,
6466
`import { defineConfig } from 'vite-plus';\n\nexport default defineConfig({\n run: { cacheScripts: true },\n});\n`,
6567
'utf-8',
6668
);
6769
}
70+
// Format the modified/created config to match project's style (avoids format check failures)
71+
try {
72+
execSync(`npx prettier --write ${JSON.stringify(viteConfigPath)}`, { cwd, stdio: 'inherit' });
73+
} catch {
74+
// prettier may not be installed; that's fine
75+
}

0 commit comments

Comments
 (0)