@@ -10,45 +10,50 @@ const fs = require('fs')
1010const rimraf = require ( 'rimraf' )
1111const mkdirp = require ( 'mkdirp' )
1212const path = require ( 'path' )
13+ const os = require ( 'os' )
14+ const isWindows = os . platform ( ) === 'win32'
1315
1416describe ( 'ipfs executable path' , ( ) => {
17+ const tmp = os . tmpdir ( )
18+ const appName = isWindows ? 'ipfs.exe' : 'ipfs'
19+
1520 it ( 'has the correct path when installed with npm3' , ( done ) => {
16- process . env . testpath = '/ tmp/ ipfsd-ctl-test/node_modules/ipfsd-ctl/lib' // fake __dirname
17- let npm3Path = '/ tmp/ ipfsd-ctl-test/node_modules/go-ipfs-dep/go-ipfs'
21+ process . env . testpath = path . join ( tmp , ' ipfsd-ctl-test/node_modules/ipfsd-ctl/lib') // fake __dirname
22+ let npm3Path = path . join ( tmp , ' ipfsd-ctl-test/node_modules/go-ipfs-dep/go-ipfs')
1823
1924 mkdirp ( npm3Path , ( err ) => {
2025 expect ( err ) . to . not . exist ( )
2126
22- fs . writeFileSync ( path . join ( npm3Path , 'ipfs' ) )
27+ fs . writeFileSync ( path . join ( npm3Path , appName ) )
2328 delete require . cache [ require . resolve ( '../src/daemon.js' ) ]
2429 const Daemon = require ( '../src/daemon.js' )
2530
2631 const node = new Daemon ( )
2732 expect ( node . exec )
28- . to . eql ( path . normalize ( '/ tmp/ ipfsd-ctl-test/node_modules/go-ipfs-dep/go-ipfs/ipfs' ) )
29- rimraf ( '/ tmp/ ipfsd-ctl-test', done )
33+ . to . eql ( path . join ( tmp , ` ipfsd-ctl-test/node_modules/go-ipfs-dep/go-ipfs/${ appName } ` ) )
34+ rimraf ( path . join ( tmp , ' ipfsd-ctl-test') , done )
3035 } )
3136 } )
3237
3338 it ( 'has the correct path when installed with npm2' , ( done ) => {
34- process . env . testpath = '/ tmp/ ipfsd-ctl-test/node_modules/ipfsd-ctl/lib' // fake __dirname
39+ process . env . testpath = path . join ( tmp , ' ipfsd-ctl-test/node_modules/ipfsd-ctl/lib') // fake __dirname
3540
36- let npm2Path = '/ tmp/ ipfsd-ctl-test/node_modules/ipfsd-ctl/node_modules/go-ipfs-dep/go-ipfs'
41+ let npm2Path = path . join ( tmp , ' ipfsd-ctl-test/node_modules/ipfsd-ctl/node_modules/go-ipfs-dep/go-ipfs')
3742
3843 mkdirp ( npm2Path , ( err ) => {
3944 expect ( err ) . to . not . exist ( )
4045
41- fs . writeFileSync ( path . join ( npm2Path , 'ipfs' ) )
46+ fs . writeFileSync ( path . join ( npm2Path , appName ) )
4247 delete require . cache [ require . resolve ( '../src/daemon.js' ) ]
4348 const Daemon = require ( '../src/daemon.js' )
4449
4550 const node = new Daemon ( )
4651
4752 expect ( node . exec )
4853 . to . eql (
49- path . normalize ( '/ tmp/ ipfsd-ctl-test/node_modules/ipfsd-ctl/node_modules/go-ipfs-dep/go-ipfs/ipfs' )
54+ path . join ( tmp , ` ipfsd-ctl-test/node_modules/ipfsd-ctl/node_modules/go-ipfs-dep/go-ipfs/${ appName } ` )
5055 )
51- rimraf ( '/ tmp/ ipfsd-ctl-test', done )
56+ rimraf ( path . join ( tmp , ' ipfsd-ctl-test') , done )
5257 } )
5358 } )
5459} )
0 commit comments