mirror of
https://github.com/simstudioai/sim.git
synced 2026-11-22 21:28:37 +08:00
* improvement(audits): eliminate repeated parsing and scans * fix(audits): resolve local bins under vitest * fix(audits): include drizzle subpath imports
21 lines
559 B
TypeScript
21 lines
559 B
TypeScript
import { spawnSync } from 'node:child_process'
|
|
import { localBin } from './local-bin'
|
|
|
|
export function formatGeneratedSource(source: string, stdinFilePath: string, cwd: string): string {
|
|
const result = spawnSync(localBin('biome'), ['format', '--stdin-file-path', stdinFilePath], {
|
|
cwd,
|
|
encoding: 'utf8',
|
|
input: source,
|
|
})
|
|
|
|
if (result.status !== 0) {
|
|
throw new Error(
|
|
`Failed to format generated source for ${stdinFilePath}:\n${
|
|
result.stderr || result.stdout || 'unknown error'
|
|
}`
|
|
)
|
|
}
|
|
|
|
return result.stdout
|
|
}
|