This repository was archived by the owner on Feb 12, 2024. It is now read-only.
File tree 3 files changed +29
-2
lines changed 3 files changed +29
-2
lines changed Original file line number Diff line number Diff line change @@ -2,6 +2,7 @@ const Command = require('ronin').Command
2
2
const IpfsRepo = require ( 'ipfs-repo' )
3
3
const Ipfs = require ( '../../core' )
4
4
const fsBlobStore = require ( 'fs-blob-store' )
5
+ const utils = require ( '../utils' )
5
6
6
7
module . exports = Command . extend ( {
7
8
desc : 'Initialize a local IPFS local node' ,
@@ -26,7 +27,9 @@ module.exports = Command.extend({
26
27
} ,
27
28
28
29
run : ( bits , force , empty ) => {
29
- const repo = new IpfsRepo ( '/tmp/my-little-repo' , {
30
+ const path = utils . getRepoPath ( )
31
+
32
+ const repo = new IpfsRepo ( path , {
30
33
stores : {
31
34
keys : fsBlobStore ,
32
35
config : fsBlobStore ,
Original file line number Diff line number Diff line change @@ -44,3 +44,7 @@ exports.getIPFS = (callback) => {
44
44
45
45
callback ( null , getAPICtl ( ) )
46
46
}
47
+
48
+ exports . getRepoPath = ( ) => {
49
+ return repoPath
50
+ }
Original file line number Diff line number Diff line change 2
2
3
3
const expect = require ( 'chai' ) . expect
4
4
const nexpect = require ( 'nexpect' )
5
+ const rimraf = require ( 'rimraf' )
6
+
7
+ describe ( 'init' , function ( ) {
8
+ this . timeout ( 10000 )
9
+
10
+ var oldRepoPath = process . env . IPFS_PATH
11
+ before ( ( done ) => {
12
+ oldRepoPath = process . env . IPFS_PATH
13
+ console . log ( 'old' , oldRepoPath )
14
+ const repoPath = '/tmp/ipfs-test-' + Math . random ( ) . toString ( ) . substring ( 2 , 8 ) + '/'
15
+ process . env . IPFS_PATH = repoPath
16
+ done ( )
17
+ } )
18
+
19
+ after ( ( done ) => {
20
+ rimraf ( process . env . IPFS_PATH , ( err ) => {
21
+ expect ( err ) . to . not . exist
22
+ process . env . IPFS_PATH = oldRepoPath
23
+ done ( )
24
+ } )
25
+ } )
5
26
6
- describe ( 'init' , ( ) => {
7
27
it ( 'basic' , ( done ) => {
8
28
nexpect . spawn ( 'node' , [ process . cwd ( ) + '/src/cli/bin.js' , 'init' ] )
9
29
. run ( ( err , stdout , exitcode ) => {
You can’t perform that action at this time.
0 commit comments