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

Commit

Permalink
Merge pull request #130 from Dignifiedquire/log
Browse files Browse the repository at this point in the history
feat: Fix log/tail for 0.3.9
  • Loading branch information
dignifiedquire committed Nov 21, 2015
2 parents 59c84e7 + 76f5d2b commit 0b7ff96
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 6 deletions.
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) => {
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) {
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

0 comments on commit 0b7ff96

Please sign in to comment.