@@ -4,33 +4,33 @@ import npmRunPath from '.';
4
4
5
5
test ( 'main' , t => {
6
6
t . is (
7
- npmRunPath ( { path : '' } ) . split ( path . delimiter ) [ 1 ] ,
7
+ npmRunPath ( { path : '' } ) . split ( path . delimiter ) [ 0 ] ,
8
8
path . join ( __dirname , 'node_modules/.bin' )
9
9
) ;
10
10
11
11
t . is (
12
- npmRunPath . env ( { env : { PATH : 'foo' } } ) . PATH . split ( path . delimiter ) [ 1 ] ,
12
+ npmRunPath . env ( { env : { PATH : 'foo' } } ) . PATH . split ( path . delimiter ) [ 0 ] ,
13
13
path . join ( __dirname , 'node_modules/.bin' )
14
14
) ;
15
15
} ) ;
16
16
17
- test ( 'push `execPath` to the front of the PATH' , t => {
18
- t . is (
19
- npmRunPath ( { path : '' } ) . split ( path . delimiter ) [ 0 ] ,
20
- path . dirname ( process . execPath )
21
- ) ;
17
+ test ( 'push `execPath` later in the PATH' , t => {
18
+ const pathEnv = npmRunPath ( { path : '' } ) . split ( path . delimiter ) ;
19
+ t . is ( pathEnv [ pathEnv . length - 2 ] , path . dirname ( process . execPath ) ) ;
22
20
} ) ;
23
21
24
22
test ( 'can change `execPath` with the `execPath` option' , t => {
25
- t . is (
26
- npmRunPath ( { path : '' , execPath : 'test/test' } ) . split ( path . delimiter ) [ 0 ] ,
27
- path . resolve ( process . cwd ( ) , 'test' )
23
+ const pathEnv = npmRunPath ( { path : '' , execPath : 'test/test' } ) . split (
24
+ path . delimiter
28
25
) ;
26
+ t . is ( pathEnv [ pathEnv . length - 2 ] , path . resolve ( process . cwd ( ) , 'test' ) ) ;
29
27
} ) ;
30
28
31
29
test ( 'the `execPath` option is relative to the `cwd` option' , t => {
32
- t . is (
33
- npmRunPath ( { path : '' , execPath : 'test/test' , cwd : '/dir' } ) . split ( path . delimiter ) [ 0 ] ,
34
- path . normalize ( '/dir/test' )
35
- ) ;
30
+ const pathEnv = npmRunPath ( {
31
+ path : '' ,
32
+ execPath : 'test/test' ,
33
+ cwd : '/dir'
34
+ } ) . split ( path . delimiter ) ;
35
+ t . is ( pathEnv [ pathEnv . length - 2 ] , path . normalize ( '/dir/test' ) ) ;
36
36
} ) ;
0 commit comments