Skip to content

Commit d4082db

Browse files
committed
fix: only require http api client if it has not been specified
If we configure which http api module to use, don't try to require `ipfs-http-client`, because that then means the containing project needs to specify a dependency on `ipfs-http-client` when the containing project might actually be `ipfs-http-client`...
1 parent 025c06f commit d4082db

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

src/factory.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,14 @@ const defaults = {
2121
type: 'go',
2222
env: {},
2323
args: [],
24+
<<<<<<< HEAD
2425
ipfsHttpModule: {
2526
path: require.resolve('ipfs-http-client'),
2627
ref: require('ipfs-http-client')
2728
},
2829
ipfsModule: {},
30+
=======
31+
>>>>>>> fix: only require http api client if it has not been specified
2932
ipfsOptions: {},
3033
forceKill: true,
3134
forceKillTimeout: 5000
@@ -126,6 +129,16 @@ class Factory {
126129
options
127130
)
128131

132+
// only include the http api client if it has not been specified as an option
133+
// for example if we are testing the http api client itself we should not try
134+
// to require 'ipfs-http-client'
135+
if (!opts.ipfsHttpModule) {
136+
opts.ipfsHttpModule = {
137+
path: require.resolve('ipfs-http-client'),
138+
ref: require('ipfs-http-client')
139+
}
140+
}
141+
129142
// IPFS options defaults
130143
const ipfsOptions = merge(
131144
{

0 commit comments

Comments
 (0)