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

Commit 9b385ae

Browse files
haadcodedaviddias
authored andcommitted
fix: promisify node.stop (#1082)
* fix: stop() returns a Promise * chore: Make linter happy
1 parent 35687cb commit 9b385ae

File tree

4 files changed

+21
-5
lines changed

4 files changed

+21
-5
lines changed

src/cli/commands/ls.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
'use strict'
22

33
const utils = require('../utils')
4-
const Unixfs = require('ipfs-unixfs')
5-
const pull = require('pull-stream')
64

75
module.exports = {
86
command: 'ls <key>',

src/core/components/stop.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
'use strict'
22

33
const series = require('async/series')
4+
const promisify = require('promisify-es6')
45

56
module.exports = (self) => {
6-
return (callback) => {
7+
return promisify((callback) => {
78
callback = callback || function noop () {}
89
self.log('stop')
910

@@ -40,5 +41,5 @@ module.exports = (self) => {
4041
(cb) => self.libp2p.stop(cb),
4142
(cb) => self._repo.close(cb)
4243
], done)
43-
}
44+
})
4445
}

src/http/api/resources/files.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -317,4 +317,3 @@ function toTypeCode (type) {
317317
return 0
318318
}
319319
}
320-

test/core/create-node.spec.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,24 @@ describe('create node', function () {
244244
], done)
245245
})
246246

247+
it('stop as promised', function (done) {
248+
const node = new IPFS({
249+
repo: createTempRepo(),
250+
config: {
251+
Addresses: {
252+
Swarm: []
253+
},
254+
Bootstrap: []
255+
}
256+
})
257+
258+
node.once('ready', () => {
259+
node.stop()
260+
.then(done)
261+
.catch(done)
262+
})
263+
})
264+
247265
it('can start node twice without crash', function (done) {
248266
const options = {
249267
repo: createTempRepo(),

0 commit comments

Comments
 (0)