Skip to content
This repository has been archived by the owner on Feb 12, 2024. It is now read-only.

Commit

Permalink
fix: use passed in repo location in the browser
Browse files Browse the repository at this point in the history
  • Loading branch information
dignifiedquire committed May 26, 2016
1 parent 4502d66 commit 4b55102
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 7 deletions.
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@
"boom": "^3.1.2",
"bs58": "^3.0.0",
"debug": "^2.2.0",
"detect-node": "^2.0.3",
"fs-blob-store": "^5.2.1",
"glob": "^7.0.3",
"hapi": "^13.4.1",
Expand Down Expand Up @@ -122,4 +123,4 @@
"kumavis <kumavis@users.noreply.github.com>",
"nginnever <ginneversource@gmail.com>"
]
}
}
5 changes: 3 additions & 2 deletions src/core/default-repo/browser.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
const idb = require('idb-plus-blob-store')
const IPFSRepo = require('ipfs-repo')

module.exports = () => {
return new IPFSRepo('ipfs', {stores: idb})
module.exports = (dir) => {
const repoPath = dir || 'ipfs'
return new IPFSRepo(repoPath, {stores: idb})
}
2 changes: 1 addition & 1 deletion src/core/default-repo/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use strict'

const isNode = !global.window
const isNode = require('detect-node')

module.exports = isNode
? require('./node')
Expand Down
2 changes: 1 addition & 1 deletion src/core/ipfs/init.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ module.exports = function init (self) {
// Add the default assets to the repo.
function addDefaultAssets () {
// Skip this step on the browser, or if emptyRepo was supplied.
const isNode = !global.window
const isNode = require('detect-node')
if (!isNode || opts.emptyRepo) {
return doneImport(null)
}
Expand Down
2 changes: 1 addition & 1 deletion test/core-tests/test-block.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const IPFS = require('../../src/core')
const Block = require('ipfs-block')
const path = require('path')

const isNode = !global.window
const isNode = require('detect-node')

const fileA = isNode
? fs.readFileSync(path.join(__dirname, '../go-ipfs-repo/blocks/12207028/122070286b9afa6620a66f715c7020d68af3d10e1a497971629c07606bfdb812303d.data'))
Expand Down
2 changes: 1 addition & 1 deletion test/utils/temp-repo.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ function createTempRepo () {
let store
let teardown

const isNode = !global.window
const isNode = require('detect-node')
if (isNode) {
store = require('fs-blob-store')
teardown = (done) => {
Expand Down

0 comments on commit 4b55102

Please sign in to comment.