Skip to content

Commit

Permalink
fix: use IPFS_PATH env var
Browse files Browse the repository at this point in the history
non disposable controllers should use IPFS_PATH if set.

closes #497
  • Loading branch information
hugomrdias committed Apr 20, 2020
1 parent f8decb3 commit 708c7cc
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ const repoExists = async (repoPath) => {
}

const defaultRepo = (type) => {
if (process.env.IPFS_PATH !== undefined) {
return process.env.IPFS_PATH
}
return path.join(
os.homedir(),
type === 'js' || type === 'proc' ? '.jsipfs' : '.ipfs'
Expand Down
15 changes: 15 additions & 0 deletions test/controller.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,21 @@ describe('Controller API', function () {
after(() => factory.clean())

describe('init', () => {
it('should use process.IPFS_PATH', async () => {
const repoPath = await factory.tmpDir()
process.env.IPFS_PATH = repoPath
const ctl = await factory.spawn({
type: 'go',
disposable: false,
ipfsOptions: {
init: false,
start: false
}
})

expect(ctl.path).to.equal(repoPath)
process.env.IPFS_PATH = undefined
})
describe('should work with defaults', () => {
for (const opts of types) {
it(`type: ${opts.type} remote: ${Boolean(opts.remote)}`, async () => {
Expand Down

0 comments on commit 708c7cc

Please sign in to comment.