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

Commit 6f70f83

Browse files
committed
Merge pull request #273 from ipfs/fix/repo-path
fix: use passed in repo location in the browser
2 parents 1132fec + 4b55102 commit 6f70f83

File tree

6 files changed

+9
-7
lines changed

6 files changed

+9
-7
lines changed

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@
6060
"boom": "^3.1.2",
6161
"bs58": "^3.0.0",
6262
"debug": "^2.2.0",
63+
"detect-node": "^2.0.3",
6364
"fs-blob-store": "^5.2.1",
6465
"glob": "^7.0.3",
6566
"hapi": "^13.4.1",
@@ -122,4 +123,4 @@
122123
"kumavis <kumavis@users.noreply.github.com>",
123124
"nginnever <ginneversource@gmail.com>"
124125
]
125-
}
126+
}

src/core/default-repo/browser.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
const idb = require('idb-plus-blob-store')
44
const IPFSRepo = require('ipfs-repo')
55

6-
module.exports = () => {
7-
return new IPFSRepo('ipfs', {stores: idb})
6+
module.exports = (dir) => {
7+
const repoPath = dir || 'ipfs'
8+
return new IPFSRepo(repoPath, {stores: idb})
89
}

src/core/default-repo/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
'use strict'
22

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

55
module.exports = isNode
66
? require('./node')

src/core/ipfs/init.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ module.exports = function init (self) {
6767
// Add the default assets to the repo.
6868
function addDefaultAssets () {
6969
// Skip this step on the browser, or if emptyRepo was supplied.
70-
const isNode = !global.window
70+
const isNode = require('detect-node')
7171
if (!isNode || opts.emptyRepo) {
7272
return doneImport(null)
7373
}

test/core-tests/test-block.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ const IPFS = require('../../src/core')
88
const Block = require('ipfs-block')
99
const path = require('path')
1010

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

1313
const fileA = isNode
1414
? fs.readFileSync(path.join(__dirname, '../go-ipfs-repo/blocks/12207028/122070286b9afa6620a66f715c7020d68af3d10e1a497971629c07606bfdb812303d.data'))

test/utils/temp-repo.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ function createTempRepo () {
1010
let store
1111
let teardown
1212

13-
const isNode = !global.window
13+
const isNode = require('detect-node')
1414
if (isNode) {
1515
store = require('fs-blob-store')
1616
teardown = (done) => {

0 commit comments

Comments
 (0)