Skip to content
This repository was archived by the owner on Mar 10, 2020. It is now read-only.

Commit d4b6299

Browse files
feat: Fix log/tail for 0.3.9
1 parent 1b6fd6c commit d4b6299

File tree

3 files changed

+14
-6
lines changed

3 files changed

+14
-6
lines changed

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
"merge-stream": "^1.0.0",
88
"multiaddr": "^1.0.0",
99
"multipart-stream": "^2.0.0",
10+
"ndjson": "^1.4.3",
1011
"qs": "^6.0.0",
1112
"vinyl": "^1.1.0",
1213
"vinyl-fs-browser": "^2.1.1-1",

src/index.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ const multiaddr = require('multiaddr')
44
const getConfig = require('./config')
55
const getRequestAPI = require('./request-api')
66
const Wreck = require('wreck')
7+
const ndjson = require('ndjson')
78

89
exports = module.exports = IpfsAPI
910

@@ -203,7 +204,10 @@ function IpfsAPI (host_or_multiaddr, port) {
203204

204205
self.log = {
205206
tail (cb) {
206-
return requestAPI('log/tail', null, {enc: 'text'}, null, true, cb)
207+
requestAPI('log/tail', null, {}, null, false, (err, res) => {
208+
if (err) return cb(err)
209+
cb(null, res.pipe(ndjson.parse()))
210+
})
207211
}
208212
}
209213

test/tests.js

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -640,15 +640,18 @@ describe('IPFS Node.js API wrapper tests', () => {
640640
})
641641

642642
describe('.log', function () {
643-
// TODO news 0.3.9 ndjson stuff
644-
it.skip('.log.tail', function (done) {
643+
it('.log.tail', function (done) {
644+
this.timeout(10000)
645+
645646
apiClients['a'].log.tail((err, res) => {
646647
if (err) {
647648
throw err
648649
}
649-
650-
console.log('->', res)
651-
done()
650+
res.once('data', obj => {
651+
assert(obj)
652+
assert.equal(typeof obj, 'object')
653+
done()
654+
})
652655
})
653656
})
654657
})

0 commit comments

Comments
 (0)