Skip to content

Commit e29690f

Browse files
committed
fix: various fixes from @vmx review
1 parent aa8d72b commit e29690f

File tree

6 files changed

+19
-26
lines changed

6 files changed

+19
-26
lines changed

README.md

+12-12
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ server.start((err) => {
131131
- **`js`** - calling `DaemonFactory.create({type: 'js'})` will spawn a `js-ipfs` daemon.
132132
- **`proc`** - calling `DaemonFactory.create({type: 'proc', exec: require('ipfs') })` will spawn an `in process js-ipfs node` using the provided code reference that implements the core IPFS API. Note that, `exec` option to `df.spawn()` is required if `type: 'proc'` is used.
133133

134-
#### DaemonFactory endpoint for remote spawning - `const server = DaemonFactory.createServer([options]) `
134+
#### DaemonFactory endpoint for remote spawning - `const server = `DaemonFactory.createServer([options]) `
135135

136136
`DaemonFactory.createServer` create an instance of the bundled REST API used by the remote controller.
137137

@@ -162,15 +162,15 @@ The IPFS daemon controller (`ipfsd`) allows you to interact with the spawned IPF
162162

163163
#### `ipfsd.apiAddr` (getter)
164164

165-
Get the address (multiaddr) of connected IPFS API. Returns a multiaddr,
165+
Get the address (multiaddr) of connected IPFS API. Returns a multiaddr
166166

167167
#### `ipfsd.gatewayAddr` (getter)
168168

169169
Get the address (multiaddr) of connected IPFS HTTP Gateway. Returns a multiaddr.
170170

171171
#### `ipfsd.repoPath` (getter)
172172

173-
Get the current repo path. Returns string
173+
Get the current repo path. Returns string.
174174

175175
#### `ipfsd.started` (getter)
176176

@@ -181,7 +181,7 @@ Is the node started. Returns a boolean.
181181
Initialize a repo.
182182

183183
`initOpts` (optional) is an object with the following properties:
184-
- `keysize` (default 2048) - The bit size of the identiy key.
184+
- `keysize` (default 2048) - The bit size of the identity key.
185185
- `directory` (default IPFS_PATH if defined, or ~/.ipfs for go-ipfs and ~/.jsipfs for js-ipfs) - The location of the repo.
186186

187187
`callback` is a function with the signature `function (Error, ipfsd)` where `err` is an Error in case something goes wrong and `ipfsd` is the daemon controller instance.
@@ -198,36 +198,36 @@ Start the daemon.
198198

199199
`flags` - Flags array to be passed to the `ipfs daemon` command.
200200

201-
`callback` is a function with the signature `function(err, ipfsApi)}` that receives an instance of `ipfs-api` on success or an instance of `Error` on failure
201+
`callback` is a function with the signature `function(err, ipfsApi)` that receives an instance of `ipfs-api` on success or an instance of `Error` on failure
202202

203203

204-
#### `ipfsd.stop(callback)`
204+
#### `ipfsd.stop([callback])`
205205

206206
Stop the daemon.
207207

208208
`callback` is a function with the signature `function(err)` callback - function that receives an instance of `Error` on failure
209209

210-
#### `ipfsd.killProcess (callback)`
210+
#### `ipfsd.killProcess([callback])`
211211

212212
Kill the `ipfs daemon` process.
213213

214214
First a `SIGTERM` is sent, after 10.5 seconds `SIGKILL` is sent if the process hasn't exited yet.
215215

216216
`callback` is a function with the signature `function()` called once the process is killed
217217

218-
#### `ipfsd.pid ()`
218+
#### `ipfsd.pid()`
219219

220220
Get the pid of the `ipfs daemon` process. Returns the pid number
221221

222-
#### `ipfsd.getConfig(key, callback)`
222+
#### `ipfsd.getConfig([key], callback)`
223223

224224
Returns the output of an `ipfs config` command. If no `key` is passed, the whole config is returned as an object.
225225

226226
`key` (optional) - A specific config to retrieve.
227227

228-
`callback` is a function with the signature `function(err, (Object|string)` that receives an object or string on success or an `Error` instance on failure
228+
`callback` is a function with the signature `function(err, (Object|string))` that receives an object or string on success or an `Error` instance on failure
229229

230-
#### `ipfsd.setConfig (key, value, callback)`
230+
#### `ipfsd.setConfig(key, value, callback)`
231231

232232
Set a config value.
233233

@@ -251,7 +251,7 @@ This instance is returned for each successfully started IPFS daemon, when either
251251

252252
### Packaging
253253

254-
`ipfsd-ctl` can be packaged in Electron applications, but the ipfs binary has to be excluded from asar (Electron Archives),
254+
`ipfsd-ctl` can be packaged in Electron applications, but the ipfs binary has to be excluded from asar (Electron Archives).
255255
[read more about unpack files from asar](https://electron.atom.io/docs/tutorial/application-packaging/#adding-unpacked-files-in-asar-archive).
256256

257257
`ipfsd-ctl` will try to detect if used from within an `app.asar` archive and tries to resolve ipfs from `app.asar.unpacked`. The ipfs binary is part of the `go-ipfs-dep` module.

src/index.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ class DaemonFactory {
99
static create (opts) {
1010
const options = defaults({}, opts, { remote: !isNode })
1111

12-
if (options.remote && options.type === 'proc') {
12+
if (options.type === 'proc') {
1313
options.remote = false
1414
}
1515

src/remote-node/client.js

+3-2
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,7 @@ class Node {
152152
* @returns {undefined}
153153
*/
154154
stop (cb) {
155+
cb = cb || (() => {})
155156
request
156157
.post(`${this.baseUrl}/stop`)
157158
.query({ id: this._id })
@@ -219,11 +220,11 @@ class Node {
219220
getConfig (key, cb) {
220221
if (typeof key === 'function') {
221222
cb = key
222-
key = null
223+
key = undefined
223224
}
224225

225226
const qr = { id: this._id }
226-
qr.key = key || undefined
227+
qr.key = key
227228
request
228229
.get(`${this.baseUrl}/config`)
229230
.query(qr)

test/add-retrive.js

-9
Original file line numberDiff line numberDiff line change
@@ -42,14 +42,5 @@ module.exports = () => {
4242
expect(this.ipfsd.api).to.have.property('apiHost')
4343
expect(this.ipfsd.api).to.have.property('apiPort')
4444
})
45-
46-
it('should be able to store objects', () => {
47-
expect(store)
48-
.to.equal('QmPv52ekjS75L4JmHpXVeuJ5uX2ecSfSZo88NSyxwA3rAQ')
49-
})
50-
51-
it('should be able to retrieve objects', () => {
52-
expect(retrieve.toString()).to.equal('blorb')
53-
})
5445
})
5546
}

test/api.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -100,9 +100,9 @@ module.exports = (df, type) => {
100100
// Check for props in daemon
101101
expect(ipfsd).to.have.property('apiAddr')
102102
expect(ipfsd).to.have.property('gatewayAddr')
103-
expect(ipfsd.apiAddr).to.not.equal(null)
103+
expect(ipfsd.apiAddr).to.not.be.null()
104104
expect(multiaddr.isMultiaddr(ipfsd.apiAddr)).to.equal(true)
105-
expect(ipfsd.gatewayAddr).to.not.equal(null)
105+
expect(ipfsd.gatewayAddr).to.not.be.null()
106106
expect(multiaddr.isMultiaddr(ipfsd.gatewayAddr)).to.equal(true)
107107

108108
// Check for props in ipfs-api instance

test/remote/routes.js

+1
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ const routes = proxyquire('../../src/remote-node/routes', {
4343
node.stop = (cb) => {
4444
node.killProcess(cb)
4545
}
46+
4647
node.killProcess = (cb) => {
4748
node.started = false
4849
cb()

0 commit comments

Comments
 (0)