diff --git a/src/utils.js b/src/utils.js index dace41f9..9067a0d7 100644 --- a/src/utils.js +++ b/src/utils.js @@ -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' diff --git a/test/controller.spec.js b/test/controller.spec.js index cb48b505..d13392da 100644 --- a/test/controller.spec.js +++ b/test/controller.spec.js @@ -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 () => {