From 5b53e220f1d64f63e2bb23f76cda1e488c5b192b Mon Sep 17 00:00:00 2001 From: achingbrain Date: Thu, 3 Oct 2019 08:36:17 +0100 Subject: [PATCH] fix: get correct remote node config I noticed some calls would fail during tests when the daemon was listening on non-standard ports, this was because when commands `require` other commands that use `ky`, we are passing the `ky` instance in as the sole property of an object that usually contains the host and port number of the remote node's API server. --- src/add-from-fs/index.js | 7 +++---- src/add-from-url.js | 7 +++---- src/pubsub/subscribe.js | 5 +++-- 3 files changed, 9 insertions(+), 10 deletions(-) diff --git a/src/add-from-fs/index.js b/src/add-from-fs/index.js index 01a82e166..7403f7e46 100644 --- a/src/add-from-fs/index.js +++ b/src/add-from-fs/index.js @@ -1,9 +1,8 @@ 'use strict' -const configure = require('../lib/configure') const globSource = require('ipfs-utils/src/files/glob-source') -module.exports = configure(({ ky }) => { - const add = require('../add')({ ky }) +module.exports = (config) => { + const add = require('../add')(config) return (path, options) => add(globSource(path, options), options) -}) +} diff --git a/src/add-from-url.js b/src/add-from-url.js index 336906ea1..388072984 100644 --- a/src/add-from-url.js +++ b/src/add-from-url.js @@ -1,11 +1,10 @@ 'use strict' const kyDefault = require('ky-universal').default -const configure = require('./lib/configure') const toIterable = require('./lib/stream-to-iterable') -module.exports = configure(({ ky }) => { - const add = require('./add')({ ky }) +module.exports = (config) => { + const add = require('./add')(config) return (url, options) => (async function * () { options = options || {} @@ -19,4 +18,4 @@ module.exports = configure(({ ky }) => { yield * add(input, options) })() -}) +} diff --git a/src/pubsub/subscribe.js b/src/pubsub/subscribe.js index ae95ec5c8..7950a274a 100644 --- a/src/pubsub/subscribe.js +++ b/src/pubsub/subscribe.js @@ -9,9 +9,10 @@ const configure = require('../lib/configure') const toIterable = require('../lib/stream-to-iterable') const SubscriptionTracker = require('./subscription-tracker') -module.exports = configure(({ ky }) => { +module.exports = configure((config) => { + const ky = config.ky const subsTracker = SubscriptionTracker.singleton() - const publish = require('./publish')({ ky }) + const publish = require('./publish')(config) return async (topic, handler, options) => { options = options || {}