Skip to content

Commit 8d64b78

Browse files
authored
chore: remove dependency on ipfs.init() (#560)
1 parent 8fa51ce commit 8d64b78

File tree

1 file changed

+12
-8
lines changed

1 file changed

+12
-8
lines changed

src/ipfsd-in-proc.js

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ class InProc {
2222
/** @type ControllerOptions */
2323
this.opts = opts
2424
this.path = this.opts.ipfsOptions.repo || (opts.disposable ? tmpDir(opts.type) : defaultRepo(opts.type))
25+
this.initOptions = toInitOptions(opts.ipfsOptions.init)
2526
this.disposable = opts.disposable
2627
this.initialized = false
2728
this.started = false
@@ -38,10 +39,12 @@ class InProc {
3839

3940
const IPFS = this.opts.ipfsModule
4041

41-
this.api = await IPFS.create(merge({
42+
this.api = await IPFS.create({
43+
...this.opts.ipfsOptions,
4244
silent: true,
43-
repo: this.path
44-
}, this.opts.ipfsOptions))
45+
repo: this.path,
46+
init: this.initOptions
47+
})
4548
}
4649

4750
/**
@@ -79,18 +82,16 @@ class InProc {
7982
}
8083

8184
// Repo not initialized
82-
const opts = merge(
85+
this.initOptions = merge(
8386
{
8487
emptyRepo: false,
8588
profiles: this.opts.test ? ['test'] : []
8689
},
87-
typeof this.opts.ipfsOptions.init === 'boolean' ? {} : this.opts.ipfsOptions.init,
88-
typeof initOptions === 'boolean' ? {} : initOptions
90+
this.initOptions,
91+
toInitOptions(initOptions)
8992
)
9093

9194
await this.setExec()
92-
await this.api.init(opts)
93-
9495
this.clean = false
9596
this.initialized = true
9697
return this
@@ -173,4 +174,7 @@ class InProc {
173174
}
174175
}
175176

177+
const toInitOptions = (init) =>
178+
typeof init === 'boolean' ? {} : init
179+
176180
module.exports = InProc

0 commit comments

Comments
 (0)