@@ -6,6 +6,7 @@ const ipfsApi = require('ipfs-api')
6
6
const run = require ( 'subcomandante' )
7
7
const fs = require ( 'fs' )
8
8
const rimraf = require ( 'rimraf' )
9
+ const mkdirp = require ( 'mkdirp' )
9
10
const path = require ( 'path' )
10
11
11
12
// this comment is used by mocha, do not delete
@@ -15,28 +16,34 @@ describe('ipfs executable path', function () {
15
16
this . timeout ( 2000 )
16
17
let Node
17
18
18
- it ( 'has the correct path when used via Electron' , ( ) => {
19
- process . versions [ 'electron' ] = '0.0.0-test' // Electron sets its version to the array --> we know that we're using Electron
20
- process . resourcesPath = '/test/path/one/more' // Path to the Electron app, set by Electron
21
-
22
- // Force reload of the module (pathing is handled globally in ../lib/node.js)
23
- delete require . cache [ require . resolve ( '../lib/node.js' ) ]
24
- Node = require ( '../lib/node.js' )
25
-
26
- var node = new Node ( )
27
- assert . equal ( node . exec , path . join ( process . resourcesPath , '/app' , 'node_modules/go-ipfs-dep/go-ipfs/ipfs' ) )
19
+ it ( 'has the correct path when installed with npm3' , ( done ) => {
20
+ process . env . testpath = '/tmp/ipfsd-ctl-test/node_modules/ipfsd-ctl/lib' // fake __dirname
21
+ let npm3Path = '/tmp/ipfsd-ctl-test/node_modules/go-ipfs-dep/go-ipfs'
22
+
23
+ mkdirp ( npm3Path , ( err ) => {
24
+ if ( err ) console . log ( err )
25
+ fs . writeFileSync ( path . join ( npm3Path , 'ipfs' ) )
26
+ delete require . cache [ require . resolve ( '../lib/node.js' ) ]
27
+ Node = require ( '../lib/node.js' )
28
+ var node = new Node ( )
29
+ assert . equal ( node . exec , '/tmp/ipfsd-ctl-test/node_modules/go-ipfs-dep/go-ipfs/ipfs' )
30
+ rimraf ( '/tmp/ipfsd-ctl-test' , done )
31
+ } )
28
32
} )
29
33
30
- it ( 'has the correct path when used via Node.js' , ( ) => {
31
- delete process . versions [ 'electron' ]
32
- delete process . resourcesPath
33
-
34
- // Force reload of the module (pathing is handled globally in ../lib/node.js)
35
- delete require . cache [ require . resolve ( '../lib/node.js' ) ]
36
- Node = require ( '../lib/node.js' )
37
-
38
- var node = new Node ( )
39
- assert . equal ( node . exec , path . join ( process . cwd ( ) , 'node_modules/go-ipfs-dep/go-ipfs/ipfs' ) )
34
+ it ( 'has the correct path when installed with npm2' , ( done ) => {
35
+ process . env . testpath = '/tmp/ipfsd-ctl-test/node_modules/ipfsd-ctl/lib' // fake __dirname
36
+ let npm2Path = '/tmp/ipfsd-ctl-test/node_modules/ipfsd-ctl/node_modules/go-ipfs-dep/go-ipfs'
37
+
38
+ mkdirp ( npm2Path , ( err ) => {
39
+ if ( err ) console . log ( err )
40
+ fs . writeFileSync ( path . join ( npm2Path , 'ipfs' ) )
41
+ delete require . cache [ require . resolve ( '../lib/node.js' ) ]
42
+ Node = require ( '../lib/node.js' )
43
+ var node = new Node ( )
44
+ assert . equal ( node . exec , '/tmp/ipfsd-ctl-test/node_modules/ipfsd-ctl/node_modules/go-ipfs-dep/go-ipfs/ipfs' )
45
+ rimraf ( '/tmp/ipfsd-ctl-test' , done )
46
+ } )
40
47
} )
41
48
} )
42
49
@@ -353,7 +360,7 @@ describe('ipfs-api version', function () {
353
360
354
361
const added = res [ res . length - 1 ]
355
362
assert ( added )
356
- assert . equal ( added . Hash , 'QmTioWzyNf4ybt6RDYCxqWBGYBfDqFWCoNwRKF89xgUvgF ' )
363
+ assert . equal ( added . Hash , 'QmdZt3Uiv3HZkHPsjGyWbrX1kMiRjst8cxQYsUjMqbXc7G ' )
357
364
done ( )
358
365
} )
359
366
} )
0 commit comments