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

Commit e11190b

Browse files
committed
chore: address pr comments
1 parent 024a122 commit e11190b

File tree

4 files changed

+24
-42
lines changed

4 files changed

+24
-42
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@
107107
"browser-process-platform": "~0.1.1",
108108
"cross-env": "^6.0.0",
109109
"go-ipfs-dep": "^0.4.22",
110-
"interface-ipfs-core": "ipfs/interface-js-ipfs-core#30118c715d95582eaf65fdf8cb0ee240c504cb1e",
110+
"interface-ipfs-core": "^0.117.0",
111111
"ipfsd-ctl": "^0.47.1",
112112
"nock": "^11.3.2",
113113
"stream-equal": "^1.1.1"

src/config/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ module.exports = (send, config) => {
66
set: require('./set')(send),
77
replace: require('./replace')(send),
88
profiles: {
9-
apply: require('./profiles/apply')(send),
9+
apply: require('./profiles/apply')(config),
1010
list: require('./profiles/list')(config)
1111
}
1212
}

src/config/profiles/apply.js

Lines changed: 20 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,27 @@
11
'use strict'
22

3-
const promisify = require('promisify-es6')
3+
const callbackify = require('callbackify')
4+
const configure = require('../../lib/configure')
45

5-
const toObject = function (res, callback) {
6-
if (Buffer.isBuffer(res)) {
7-
callback(null, JSON.parse(res.toString()))
8-
} else {
9-
callback(null, res)
10-
}
11-
}
6+
module.exports = configure(({ ky }) => {
7+
return callbackify.variadic(async (profile, options) => {
8+
options = options || {}
129

13-
module.exports = (send) => {
14-
return promisify((profile, opts, callback) => {
15-
if (typeof opts === 'function') {
16-
callback = opts
17-
opts = {}
18-
}
19-
20-
opts = normalizeOpts(opts)
21-
22-
send.andTransform({
23-
path: 'config/profile/apply',
24-
args: profile,
25-
qs: opts
26-
}, toObject, (err, response) => {
27-
if (err) {
28-
return callback(err)
10+
const res = await ky.post('config/profile/apply', {
11+
timeout: options.timeout,
12+
signal: options.signal,
13+
headers: options.headers,
14+
searchParams: {
15+
arg: profile,
16+
// can only pass strings or numbers as values https://github.com/sindresorhus/ky/issues/182
17+
'dry-run': options.dryRun ? 'true' : 'false'
2918
}
30-
callback(null, { old: response.OldCfg, new: response.NewCfg })
3119
})
32-
})
33-
}
3420

35-
function normalizeOpts (opts) {
36-
opts = opts || {}
37-
if (typeof opts.dryRun !== 'undefined') {
38-
opts['dry-run'] = opts.dryRun
39-
}
40-
return opts
41-
}
21+
const parsed = await res.json()
22+
23+
return {
24+
original: parsed.OldCfg, updated: parsed.NewCfg
25+
}
26+
})
27+
})

src/config/profiles/list.js

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,17 @@
11
'use strict'
22

3-
const configure = require('../../lib/configure')
43
const callbackify = require('callbackify')
4+
const configure = require('../../lib/configure')
55
const toCamel = require('../../lib/object-to-camel')
66

77
module.exports = configure(({ ky }) => {
88
return callbackify.variadic(async (options) => {
99
options = options || {}
1010

11-
const searchParams = new URLSearchParams(options.searchParams)
12-
searchParams.set('stream-channels', true)
13-
1411
const res = await ky.get('config/profile/list', {
1512
timeout: options.timeout,
1613
signal: options.signal,
17-
headers: options.headers,
18-
searchParams
14+
headers: options.headers
1915
})
2016

2117
const parsed = await res.json()

0 commit comments

Comments
 (0)