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

Commit b9836a2

Browse files
committed
chore: rebase, cleanup
1 parent 56843ba commit b9836a2

File tree

4 files changed

+37
-48
lines changed

4 files changed

+37
-48
lines changed

package.json

-2
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,6 @@
6969
"async-iterator-to-stream": "^1.1.0",
7070
"base32.js": "~0.1.0",
7171
"bignumber.js": "^9.0.0",
72-
"async-exit-hook": "^2.0.1",
7372
"binary-querystring": "~0.1.2",
7473
"bl": "^3.0.0",
7574
"bs58": "^4.0.1",
@@ -169,7 +168,6 @@
169168
"readable-stream": "^3.4.0",
170169
"receptacle": "^1.3.2",
171170
"semver": "^6.2.0",
172-
"signal-exit": "^3.0.2",
173171
"stream-to-pull-stream": "^1.7.3",
174172
"superstruct": "~0.6.0",
175173
"tar-stream": "^2.0.0",

src/cli/bin.js

+34-44
Original file line numberDiff line numberDiff line change
@@ -3,35 +3,34 @@
33
/* eslint-disable no-console */
44
'use strict'
55

6-
process.on('uncaughtException', (err) => {
7-
console.info(err)
6+
const semver = require('semver')
7+
const YargsPromise = require('yargs-promise')
8+
const updateNotifier = require('update-notifier')
9+
const debug = require('debug')('ipfs:cli')
10+
const parser = require('./parser')
11+
const commandAlias = require('./command-alias')
12+
const { print } = require('./utils')
13+
const pkg = require('../../package.json')
814

9-
throw err
15+
// Handle any uncaught error
16+
process.once('uncaughtException', (err, origin) => {
17+
if (origin === 'uncaughtException') {
18+
print(err.message)
19+
debug(err)
20+
}
1021
})
11-
12-
process.on('unhandledRejection', (err) => {
13-
console.info(err)
14-
15-
throw err
22+
process.once('unhandledRejection', (err) => {
23+
print(err.message)
24+
debug(err)
1625
})
1726

18-
const semver = require('semver')
19-
const pkg = require('../../package.json')
20-
27+
// Check for node version
2128
if (!semver.satisfies(process.versions.node, pkg.engines.node)) {
2229
console.error(`Please update your Node.js version to ${pkg.engines.node}`)
2330
process.exit(1)
2431
}
2532

26-
const YargsPromise = require('yargs-promise')
27-
const updateNotifier = require('update-notifier')
28-
const onExit = require('async-exit-hook')
29-
const utils = require('./utils')
30-
const print = utils.print
31-
const debug = require('debug')('ipfs:cli')
32-
const parser = require('./parser')
33-
const commandAlias = require('./command-alias')
34-
33+
// Check if an update is available and notify
3534
const oneWeek = 1000 * 60 * 60 * 24 * 7
3635
updateNotifier({ pkg, updateCheckInterval: oneWeek }).notify()
3736

@@ -50,30 +49,21 @@ cli
5049
}
5150
})
5251
.catch(({ error, argv }) => {
52+
console.log('TCL: error', error)
53+
5354
getIpfs = argv.getIpfs
54-
if (error) {
55-
throw error
55+
if (error.message) {
56+
print(error.message)
57+
debug(error)
58+
} else {
59+
print('Unknown error, please re-run the command with DEBUG=ipfs:cli to see debug output')
60+
debug(error)
61+
}
62+
process.exit(1)
63+
})
64+
.finally(() => {
65+
if (getIpfs && getIpfs.instance) {
66+
const cleanup = getIpfs.rest[0]
67+
return cleanup()
5668
}
57-
throw new Error('Unknown error, please re-run the command with DEBUG=ipfs:cli to see debug output')
5869
})
59-
60-
onExit(cb => {
61-
// If an IPFS instance was used in the handler then clean it up here
62-
if (getIpfs && getIpfs.instance) {
63-
const cleanup = getIpfs.rest[0]
64-
65-
return cleanup()
66-
.then(() => cb())
67-
.catch(err => {
68-
print(err.message)
69-
debug(err)
70-
cb()
71-
})
72-
}
73-
cb()
74-
})
75-
76-
onExit.unhandledRejectionHandler(err => {
77-
print(err.message)
78-
debug(err)
79-
})

src/cli/commands/id.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@ module.exports = {
1616
argv.resolve((async () => {
1717
const ipfs = await argv.getIpfs()
1818
const id = await ipfs.id()
19-
argv.print(JSON.stringify(id, '', 2))
19+
20+
return JSON.stringify(id, '', 2)
2021
})())
2122
}
2223
}

test/cli/config.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ describe('config', () => runOnAndOff((thing) => {
5858
})
5959

6060
it('set a config key with invalid json', () => {
61-
return ipfs.fail('config foo {"bar:0} --json')
61+
return ipfs.fail('config foo {"bar:0"} --json')
6262
})
6363

6464
it('get a config key value', () => {

0 commit comments

Comments
 (0)