Skip to content

Commit

Permalink
refactor!: rename filePath
Browse files Browse the repository at this point in the history
  • Loading branch information
sxzz committed Aug 26, 2023
1 parent a38c558 commit 7707713
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
16 changes: 8 additions & 8 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,12 @@ export async function run({
cwd: path.dirname(source),
})

for (const filepath of files) {
if (check) consola.info(`Checking ${filepath}`)
for (const filePath of files) {
if (check) consola.info(`Checking ${filePath}`)

const context: Context = { files, filepath }
const context: Context = { files, filePath }

const actual = await readFile(filepath, 'utf-8').catch(() => null)
const actual = await readFile(filePath, 'utf-8').catch(() => null)
let expected: string | null | undefined

if (item.type === 'text') {
Expand All @@ -51,19 +51,19 @@ export async function run({

if (check) {
if (expected === null) {
throw new TypeError(`File ${filepath} should be deleted but exists`)
throw new TypeError(`File ${filePath} should be deleted but exists`)
} else {
consola.fatal(
`File ${filepath} is not up to date, run with --write to update it.`
`File ${filePath} is not up to date, run with --write to update it.`
)
process.exit(1)
}
} else if (write) {
if (expected === null) {
// should be deleted
await unlink(filepath)
await unlink(filePath)
} else if (expected !== undefined)
await writeFile(filepath, expected, 'utf-8')
await writeFile(filePath, expected, 'utf-8')
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/types.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { type Arrayable, type Awaitable } from '@antfu/utils'

export interface Context {
filepath: string
filePath: string
files: string[]
}

Expand Down

0 comments on commit 7707713

Please sign in to comment.