Skip to content

Commit 35de914

Browse files
committed
Use handle-cli-error
1 parent 9b030f6 commit 35de914

File tree

3 files changed

+46
-9
lines changed

3 files changed

+46
-9
lines changed

package-lock.json

Lines changed: 43 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@
5353
},
5454
"dependencies": {
5555
"filter-obj": "^4.0.0",
56+
"handle-cli-error": "^1.0.0",
5657
"is-plain-obj": "^4.1.0",
5758
"keep-func-props": "^5.1.0",
5859
"moize": "^6.1.1",

src/bin/main.js

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
#!/usr/bin/env node
22
import { dirname } from 'path'
3-
import { exit } from 'process'
43
import { fileURLToPath } from 'url'
54

5+
import handleCliError from 'handle-cli-error'
66
import { readPackageUp } from 'read-pkg-up'
77
import UpdateNotifier from 'update-notifier'
88

@@ -24,7 +24,7 @@ const runCli = async function () {
2424
const output = await commandA(...args)
2525
handleOutput({ output })
2626
} catch (error) {
27-
runCliHandler(error)
27+
handleCliError(error, { short: true })
2828
}
2929
}
3030

@@ -35,11 +35,4 @@ const checkUpdate = async function () {
3535
UpdateNotifier({ pkg: packageJson }).notify()
3636
}
3737

38-
// If an error is thrown, print error's description, then exit with exit code 1
39-
const runCliHandler = function ({ message }) {
40-
console.error(message)
41-
42-
exit(1)
43-
}
44-
4538
runCli()

0 commit comments

Comments
 (0)