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

Fix: Promisify stop #1082

Merged
merged 2 commits into from
Nov 17, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions src/cli/commands/ls.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
'use strict'

const utils = require('../utils')
const Unixfs = require('ipfs-unixfs')
const pull = require('pull-stream')

module.exports = {
command: 'ls <key>',
Expand Down
5 changes: 3 additions & 2 deletions src/core/components/stop.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
'use strict'

const series = require('async/series')
const promisify = require('promisify-es6')

module.exports = (self) => {
return (callback) => {
return promisify((callback) => {
callback = callback || function noop () {}
self.log('stop')

Expand Down Expand Up @@ -40,5 +41,5 @@ module.exports = (self) => {
(cb) => self.libp2p.stop(cb),
(cb) => self._repo.close(cb)
], done)
}
})
}
1 change: 0 additions & 1 deletion src/http/api/resources/files.js
Original file line number Diff line number Diff line change
Expand Up @@ -317,4 +317,3 @@ function toTypeCode (type) {
return 0
}
}

18 changes: 18 additions & 0 deletions test/core/create-node.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,24 @@ describe('create node', function () {
], done)
})

it('stop as promised', function (done) {
const node = new IPFS({
repo: createTempRepo(),
config: {
Addresses: {
Swarm: []
},
Bootstrap: []
}
})

node.once('ready', () => {
node.stop()
.then(done)
.catch(done)
})
})

it('can start node twice without crash', function (done) {
const options = {
repo: createTempRepo(),
Expand Down