Skip to content

Commit

Permalink
fix: early return of the first provider
Browse files Browse the repository at this point in the history
  • Loading branch information
fsdiogo committed Jun 5, 2019
1 parent a58d6ec commit 22dfb4e
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,22 +33,26 @@ async function getIpfs (opts) {
const { ipfsConnectionTest } = opts

if (opts.tryCompanion) {
return tryCompanion({ root, ipfsConnectionTest })
const res = await tryCompanion({ root, ipfsConnectionTest })
if (res) return res.ipfs
}

if (opts.tryWindow) {
return tryWindow({ root, ipfsConnectionTest })
const res = await tryWindow({ root, ipfsConnectionTest })
if (res) return res.ipfs
}

if (opts.tryApi) {
const { apiAddress, defaultApiAddress } = opts
const { location } = root
return tryApi({ apiAddress, defaultApiAddress, location, IpfsApi, ipfsConnectionTest })
const res = await tryApi({ apiAddress, defaultApiAddress, location, IpfsApi, ipfsConnectionTest })
if (res) return res.ipfs
}

if (opts.tryJsIpfs) {
const { getJsIpfs, jsIpfsOpts } = opts
return tryJsIpfs({ jsIpfsOpts, getJsIpfs, ipfsConnectionTest })
const res = await tryJsIpfs({ jsIpfsOpts, getJsIpfs, ipfsConnectionTest })
if (res) return res.ipfs
}
}

Expand Down

0 comments on commit 22dfb4e

Please sign in to comment.