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

feat: Fix log/tail for 0.3.9 #130

Merged
merged 2 commits into from
Nov 21, 2015
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
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"merge-stream": "^1.0.0",
"multiaddr": "^1.0.0",
"multipart-stream": "^2.0.0",
"ndjson": "^1.4.3",
"qs": "^6.0.0",
"vinyl": "^1.1.0",
"vinyl-fs-browser": "^2.1.1-1",
Expand Down
6 changes: 5 additions & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ const multiaddr = require('multiaddr')
const getConfig = require('./config')
const getRequestAPI = require('./request-api')
const Wreck = require('wreck')
const ndjson = require('ndjson')

exports = module.exports = IpfsAPI

Expand Down Expand Up @@ -203,7 +204,10 @@ function IpfsAPI (host_or_multiaddr, port) {

self.log = {
tail (cb) {
return requestAPI('log/tail', null, {enc: 'text'}, null, true, cb)
requestAPI('log/tail', null, {}, null, false, (err, res) => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is no more need for "enc" param?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nope no need for that in 0.3.9 (it actually is ignored for log/tail)

if (err) return cb(err)
cb(null, res.pipe(ndjson.parse()))
})
}
}

Expand Down
13 changes: 8 additions & 5 deletions test/tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -619,15 +619,18 @@ describe('IPFS Node.js API wrapper tests', () => {
})

describe('.log', function () {
// TODO news 0.3.9 ndjson stuff
it.skip('.log.tail', function (done) {
it('.log.tail', function (done) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sweet! more tests :D

this.timeout(20000)

apiClients['a'].log.tail((err, res) => {
if (err) {
throw err
}

console.log('->', res)
done()
res.once('data', obj => {
assert(obj)
assert.equal(typeof obj, 'object')
done()
})
})
})
})
Expand Down