From 58e93946ee34926003c76ec603c538ffdc97d10d Mon Sep 17 00:00:00 2001 From: Irakli Gozalishvili Date: Sun, 1 Nov 2020 15:11:22 -0800 Subject: [PATCH] chore: remove dependency on ipfs.init() --- src/ipfsd-in-proc.js | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/src/ipfsd-in-proc.js b/src/ipfsd-in-proc.js index 047e891b..49426e16 100644 --- a/src/ipfsd-in-proc.js +++ b/src/ipfsd-in-proc.js @@ -22,6 +22,7 @@ class InProc { /** @type ControllerOptions */ this.opts = opts this.path = this.opts.ipfsOptions.repo || (opts.disposable ? tmpDir(opts.type) : defaultRepo(opts.type)) + this.initOptions = toInitOptions(opts.ipfsOptions.init) this.disposable = opts.disposable this.initialized = false this.started = false @@ -38,10 +39,12 @@ class InProc { const IPFS = this.opts.ipfsModule - this.api = await IPFS.create(merge({ + this.api = await IPFS.create({ + ...this.opts.ipfsOptions, silent: true, - repo: this.path - }, this.opts.ipfsOptions)) + repo: this.path, + init: this.initOptions + }) } /** @@ -79,18 +82,16 @@ class InProc { } // Repo not initialized - const opts = merge( + this.initOptions = merge( { emptyRepo: false, profiles: this.opts.test ? ['test'] : [] }, - typeof this.opts.ipfsOptions.init === 'boolean' ? {} : this.opts.ipfsOptions.init, - typeof initOptions === 'boolean' ? {} : initOptions + this.initOptions, + toInitOptions(initOptions) ) await this.setExec() - await this.api.init(opts) - this.clean = false this.initialized = true return this @@ -173,4 +174,7 @@ class InProc { } } +const toInitOptions = (init) => + typeof init === 'boolean' ? {} : init + module.exports = InProc