Skip to content

Commit

Permalink
feat: synchronous prettier formatting (#152)
Browse files Browse the repository at this point in the history
  • Loading branch information
timothympace authored Mar 7, 2024
1 parent 11534c6 commit af2ae09
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions packages/react-router/src/plugin/generate.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { exec } from 'child_process'
import { execSync } from 'child_process'
import fs from 'fs'
import path from 'path'

Expand Down Expand Up @@ -78,5 +78,5 @@ export const generate = async (options: Options) => {

if (!options.format) return
const prettier = path.resolve('./node_modules/.bin/prettier')
if (fs.existsSync(prettier)) exec(`${prettier} --write --cache ${options.output}`)
if (fs.existsSync(prettier)) execSync(`${prettier} --write --cache ${options.output}`)
}
4 changes: 2 additions & 2 deletions packages/solid-router/src/plugin/generate.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { exec } from 'child_process'
import { execSync } from 'child_process'
import fs from 'fs'
import path from 'path'

Expand Down Expand Up @@ -78,5 +78,5 @@ export const generate = async (options: Options) => {

if (!options.format) return
const prettier = path.resolve('./node_modules/.bin/prettier')
if (fs.existsSync(prettier)) exec(`${prettier} --write --cache ${options.output}`)
if (fs.existsSync(prettier)) execSync(`${prettier} --write --cache ${options.output}`)
}
4 changes: 2 additions & 2 deletions packages/tanstack-react-router/src/format.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { exec } from 'child_process'
import { execSync } from 'child_process'
import { existsSync } from 'fs'
import path from 'path'

const prettier = path.resolve('./node_modules/.bin/prettier')

export const format = (file: string) => {
if (!existsSync(prettier) || !existsSync(file)) return
exec(`${prettier} --write --cache ${file}`)
execSync(`${prettier} --write --cache ${file}`)
}

0 comments on commit af2ae09

Please sign in to comment.