Skip to content

Commit

Permalink
feat(react-query): improve cli error handling
Browse files Browse the repository at this point in the history
  • Loading branch information
gwansikk committed Dec 9, 2024
1 parent 948f078 commit d4213ce
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions packages/react-query/src/bin/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,13 @@

import { Command } from '@commander-js/extra-typings'
import { fixAction, statusAction, switchAction } from './utils/commands'
import { logger } from './utils/logger'
import { getPackageJson } from './utils/package'

const packageJson = getPackageJson()
const program = new Command(packageJson.name)
const program = new Command(packageJson.name).configureOutput({
writeErr: (str) => logger.error(str.replace('error: ', '')),
})

program
.description(packageJson.description)
Expand All @@ -25,7 +28,7 @@ program
`@tanstack/react-query's version`,
"Switch @suspensive/react-query's exports to use compatible Suspensive interfaces for @tanstack/react-query@<version>"
)
.action((version) => switchAction(version))
.action(switchAction)

program
.command('fix')
Expand All @@ -34,4 +37,10 @@ program
)
.action(fixAction)

program.parse(process.argv)
try {
program.parse(process.argv)
} catch (error) {
if (error instanceof Error) {
logger.error(error.message)
}
}

0 comments on commit d4213ce

Please sign in to comment.