Skip to content

Commit

Permalink
Merge pull request #51 from farreldarian/add-biome-support
Browse files Browse the repository at this point in the history
Biome support
  • Loading branch information
fdarian authored Apr 10, 2024
2 parents 4a98e3d + c706df4 commit ca88854
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
14 changes: 12 additions & 2 deletions packages/generator/src/generator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,18 @@ generatorHandler({
function handleFormatting() {
const generator = getGenerator()
if (generator.config.formatter == null) return

execSync(`prettier --write ${generator.output.path}`, { stdio: 'inherit' })
switch (generator.config.formatter) {
case 'prettier':
execSync(`prettier --write ${generator.output.path}`, {
stdio: 'inherit',
})
break
case 'biome':
execSync(`biome format --write ${generator.output.path}`, {
stdio: 'inherit',
})
break
}
}

export function reduceImports(imports: ImportValue[]) {
Expand Down
3 changes: 2 additions & 1 deletion packages/generator/src/lib/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {
object,
optional,
safeParse,
union,
} from 'valibot'
import { DateMode } from '~/shared/date-mode'
import { ModuleResolution } from '~/shared/generator-context/module-resolution'
Expand All @@ -16,7 +17,7 @@ const Config = object({
relationalQuery: withDefault(optional(BooleanInStr), true),
moduleResolution: optional(ModuleResolution),
verbose: optional(BooleanInStr),
formatter: optional(literal('prettier')),
formatter: optional(union([literal('prettier'), literal('biome')])),
dateMode: optional(DateMode),
})
export type Config = Output<typeof Config>
Expand Down

0 comments on commit ca88854

Please sign in to comment.