Skip to content

Commit

Permalink
fix: explicitly resolve prettier config
Browse files Browse the repository at this point in the history
  • Loading branch information
rexxars committed Dec 12, 2023
1 parent 361f609 commit deafbf4
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/util/writeFormattedFile.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import {writeFile} from 'node:fs/promises'
import {format, resolveConfig} from 'prettier'
import {readFile, writeFile} from 'node:fs/promises'
import {join as joinPath} from 'node:path'
import {format} from 'prettier'
import {getRootPath} from './getRootPath'

/**
Expand All @@ -13,7 +14,7 @@ import {getRootPath} from './getRootPath'
*/
export async function writeFormattedFile(filePath: string, content: string): Promise<void> {
const rootPath = await getRootPath()
const prettierConfig = (await resolveConfig(rootPath)) || {}
const prettierConfig = JSON.parse(await readFile(joinPath(rootPath, '.prettierrc'), 'utf8'))

const formattedCode = await format(content, {
...prettierConfig,
Expand Down

0 comments on commit deafbf4

Please sign in to comment.