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

Commit

Permalink
fix: Always return the underlying request object
Browse files Browse the repository at this point in the history
  • Loading branch information
dignifiedquire committed Dec 27, 2015
1 parent 1e18dcf commit b6e5270
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 9 deletions.
6 changes: 2 additions & 4 deletions src/api/add.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,13 @@ module.exports = send => {
}

if (typeof files === 'string' && files.startsWith('http')) {
Wreck.request('GET', files, null, (err, res) => {
return Wreck.request('GET', files, null, (err, res) => {
if (err) return cb(err)

send('add', null, opts, res, cb)
})

return
}

send('add', null, opts, files, cb)
return send('add', null, opts, files, cb)
}
}
2 changes: 1 addition & 1 deletion src/api/log.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const ndjson = require('ndjson')
module.exports = send => {
return {
tail (cb) {
send('log/tail', null, {}, null, false, (err, res) => {
return send('log/tail', null, {}, null, false, (err, res) => {
if (err) return cb(err)
cb(null, res.pipe(ndjson.parse()))
})
Expand Down
4 changes: 2 additions & 2 deletions src/api/pin.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@ module.exports = send => {
opts = null
}

send('pin/add', hash, opts, null, cb)
return send('pin/add', hash, opts, null, cb)
},
remove (hash, opts, cb) {
if (typeof opts === 'function') {
cb = opts
opts = null
}

send('pin/rm', hash, opts, null, cb)
return send('pin/rm', hash, opts, null, cb)
},
list (type, cb) {
if (typeof type === 'function') {
Expand Down
2 changes: 1 addition & 1 deletion src/request-api.js
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ function requestAPI (config, path, args, qs, files, buffer, cb) {
opts.payload = stream
}

Wreck.request(opts.method, opts.uri, opts, onRes(buffer, cb))
return Wreck.request(opts.method, opts.uri, opts, onRes(buffer, cb))
}

// -- Interface
Expand Down
4 changes: 3 additions & 1 deletion test/api/log.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@

describe('.log', () => {
it('.log.tail', done => {
apiClients['a'].log.tail((err, res) => {
const req = apiClients['a'].log.tail((err, res) => {
expect(err).to.not.exist

expect(req).to.exist

res.once('data', obj => {
expect(obj).to.be.an('object')
done()
Expand Down

0 comments on commit b6e5270

Please sign in to comment.