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

Commit b6e5270

Browse files
fix: Always return the underlying request object
1 parent 1e18dcf commit b6e5270

File tree

5 files changed

+9
-9
lines changed

5 files changed

+9
-9
lines changed

src/api/add.js

+2-4
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,13 @@ module.exports = send => {
88
}
99

1010
if (typeof files === 'string' && files.startsWith('http')) {
11-
Wreck.request('GET', files, null, (err, res) => {
11+
return Wreck.request('GET', files, null, (err, res) => {
1212
if (err) return cb(err)
1313

1414
send('add', null, opts, res, cb)
1515
})
16-
17-
return
1816
}
1917

20-
send('add', null, opts, files, cb)
18+
return send('add', null, opts, files, cb)
2119
}
2220
}

src/api/log.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ const ndjson = require('ndjson')
55
module.exports = send => {
66
return {
77
tail (cb) {
8-
send('log/tail', null, {}, null, false, (err, res) => {
8+
return send('log/tail', null, {}, null, false, (err, res) => {
99
if (err) return cb(err)
1010
cb(null, res.pipe(ndjson.parse()))
1111
})

src/api/pin.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,15 @@ module.exports = send => {
88
opts = null
99
}
1010

11-
send('pin/add', hash, opts, null, cb)
11+
return send('pin/add', hash, opts, null, cb)
1212
},
1313
remove (hash, opts, cb) {
1414
if (typeof opts === 'function') {
1515
cb = opts
1616
opts = null
1717
}
1818

19-
send('pin/rm', hash, opts, null, cb)
19+
return send('pin/rm', hash, opts, null, cb)
2020
},
2121
list (type, cb) {
2222
if (typeof type === 'function') {

src/request-api.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ function requestAPI (config, path, args, qs, files, buffer, cb) {
110110
opts.payload = stream
111111
}
112112

113-
Wreck.request(opts.method, opts.uri, opts, onRes(buffer, cb))
113+
return Wreck.request(opts.method, opts.uri, opts, onRes(buffer, cb))
114114
}
115115

116116
// -- Interface

test/api/log.spec.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,11 @@
22

33
describe('.log', () => {
44
it('.log.tail', done => {
5-
apiClients['a'].log.tail((err, res) => {
5+
const req = apiClients['a'].log.tail((err, res) => {
66
expect(err).to.not.exist
77

8+
expect(req).to.exist
9+
810
res.once('data', obj => {
911
expect(obj).to.be.an('object')
1012
done()

0 commit comments

Comments
 (0)