Skip to content
This repository was archived by the owner on Feb 12, 2024. It is now read-only.

Commit 25cdcbb

Browse files
rodkeysdaviddias
authored andcommitted
Fixed error message outputs/handling for help commands in CLI (#814)
* Fixed error message outputs/handling for help commands in CLI
1 parent 670662e commit 25cdcbb

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

src/cli/bin.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,12 @@ updateNotifier({
1616
const cli = yargs
1717
.commandDir('commands')
1818
.demandCommand(1)
19+
.fail((msg, err, yargs) => {
20+
if (err) {
21+
throw err // preserve stack
22+
}
23+
yargs.showHelp()
24+
})
1925

2026
// NOTE: This creates an alias of
2127
// `jsipfs files {add, get, cat}` to `jsipfs {add, get, cat}`.
@@ -53,6 +59,9 @@ utils.getIPFS((err, ipfs, cleanup) => {
5359
.parse(args, {
5460
ipfs: ipfs
5561
}, (err, argv, output) => {
62+
if (output) {
63+
console.log(output)
64+
}
5665
cleanup(() => {
5766
if (err) {
5867
throw err

0 commit comments

Comments
 (0)