@@ -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,40 @@ 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
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'
21
22
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' )
23
+ mkdirp ( npm3Path , ( err ) => {
24
+ if ( err ) {
25
+ console . log ( err )
26
+ }
25
27
26
- var node = new Node ( )
27
- assert . equal ( node . exec , path . join ( process . resourcesPath , '/app' , 'node_modules/go-ipfs-dep/go-ipfs/ipfs' ) )
28
+ fs . writeFileSync ( path . join ( npm3Path , 'ipfs' ) )
29
+ delete require . cache [ require . resolve ( '../lib/node.js' ) ]
30
+ Node = require ( '../lib/node.js' )
31
+ var node = new Node ( )
32
+ assert . equal ( node . exec , '/tmp/ipfsd-ctl-test/node_modules/go-ipfs-dep/go-ipfs/ipfs' )
33
+ rimraf ( '/tmp/ipfsd-ctl-test' , done )
34
+ } )
28
35
} )
29
36
30
- it ( 'has the correct path when used via Node.js ' , ( ) => {
31
- delete process . versions [ 'electron' ]
32
- delete process . resourcesPath
37
+ it ( 'has the correct path when installed with npm2 ' , ( done ) => {
38
+ process . env . testpath = '/tmp/ipfsd-ctl-test/node_modules/ipfsd-ctl/lib' // fake __dirname
39
+ let npm2Path = '/tmp/ipfsd-ctl-test/node_modules/ipfsd-ctl/node_modules/go-ipfs-dep/go-ipfs'
33
40
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' )
41
+ mkdirp ( npm2Path , ( err ) => {
42
+ if ( err ) {
43
+ console . log ( err )
44
+ }
37
45
38
- var node = new Node ( )
39
- assert . equal ( node . exec , path . join ( process . cwd ( ) , 'node_modules/go-ipfs-dep/go-ipfs/ipfs' ) )
46
+ fs . writeFileSync ( path . join ( npm2Path , 'ipfs' ) )
47
+ delete require . cache [ require . resolve ( '../lib/node.js' ) ]
48
+ Node = require ( '../lib/node.js' )
49
+ var node = new Node ( )
50
+ assert . equal ( node . exec , '/tmp/ipfsd-ctl-test/node_modules/ipfsd-ctl/node_modules/go-ipfs-dep/go-ipfs/ipfs' )
51
+ rimraf ( '/tmp/ipfsd-ctl-test' , done )
52
+ } )
40
53
} )
41
54
} )
42
55
@@ -353,7 +366,7 @@ describe('ipfs-api version', function () {
353
366
354
367
const added = res [ res . length - 1 ]
355
368
assert ( added )
356
- assert . equal ( added . Hash , 'QmTioWzyNf4ybt6RDYCxqWBGYBfDqFWCoNwRKF89xgUvgF ' )
369
+ assert . equal ( added . Hash , 'QmdZt3Uiv3HZkHPsjGyWbrX1kMiRjst8cxQYsUjMqbXc7G ' )
357
370
done ( )
358
371
} )
359
372
} )
0 commit comments