Skip to content

Commit ac5103a

Browse files
authored
feat(typegen): add optout for prettier formatting (#6702)
1 parent 74f2fd5 commit ac5103a

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

packages/@sanity/cli/src/actions/typegen/generateAction.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,10 +62,12 @@ export default async function typegenGenerateAction(
6262
const outputDir = dirname(outputPath)
6363
await mkdir(outputDir, {recursive: true})
6464

65-
const prettierConfig = await prettier.resolveConfig(outputPath).catch((err) => {
66-
output.warn(`Failed to load prettier config: ${err.message}`)
67-
return null
68-
})
65+
const prettierConfig = codegenConfig.formatGeneratedCode
66+
? await prettier.resolveConfig(outputPath).catch((err) => {
67+
output.warn(`Failed to load prettier config: ${err.message}`)
68+
return null
69+
})
70+
: null
6971
const workerPath = await getCliWorkerPath('typegenGenerate')
7072

7173
const spinner = output.spinner({}).start('Generating types')

packages/@sanity/codegen/src/readConfig.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ export const configDefintion = z.object({
1414
]),
1515
schema: z.string().default('./schema.json'),
1616
generates: z.string().default('./sanity.types.ts'),
17+
formatGeneratedCode: z.boolean().default(true),
1718
})
1819

1920
export type CodegenConfig = z.infer<typeof configDefintion>

0 commit comments

Comments
 (0)