@@ -10,10 +10,7 @@ const test = require('tap').test
10
10
const main = require ( '../index.js' )
11
11
12
12
const NPX_PATH = path . resolve ( __dirname , 'util' , 'npx-bin.js' )
13
- let NPM_PATH = path . resolve ( __dirname , '..' , 'node_modules' , '.bin' , 'npm' )
14
- if ( process . platform === 'win32' ) {
15
- NPM_PATH += '.CMD'
16
- }
13
+ let NPM_PATH = path . resolve ( __dirname , '..' , 'node_modules' , 'npm' , 'bin' , 'npm-cli.js' )
17
14
18
15
test ( 'npx --shell-auto-fallback' , t => {
19
16
return child . spawn ( 'node' , [
@@ -53,7 +50,9 @@ test('npx existing subcommand', {
53
50
} )
54
51
} )
55
52
56
- test ( 'execCommand unit' , t => {
53
+ test ( 'execCommand unit' , {
54
+ skip : process . platform === 'win32' && 'need a workaround for obnoxious auto-open of .md file on Windows'
55
+ } , t => {
57
56
let whichBin = path . resolve (
58
57
__dirname , '..' , 'node_modules' , '.bin' , 'which'
59
58
)
@@ -89,9 +88,9 @@ test('installPackages unit', t => {
89
88
const installPkgs = requireInject ( '../index.js' , {
90
89
'../child.js' : {
91
90
spawn ( npmPath , args ) {
92
- if ( args [ 1 ] === 'fail' ) {
91
+ if ( args [ 2 ] === 'fail' ) {
93
92
return Promise . reject ( new Error ( 'fail' ) )
94
- } else if ( args [ 1 ] === 'codefail' ) {
93
+ } else if ( args [ 2 ] === 'codefail' ) {
95
94
const err = new Error ( 'npm failed' )
96
95
err . exitCode = 123
97
96
return Promise . reject ( err )
@@ -109,8 +108,8 @@ test('installPackages unit', t => {
109
108
return installPkgs ( [ 'installme@latest' , 'file:foo' ] , 'myprefix' , {
110
109
npm : NPM_PATH
111
110
} ) . then ( deets => {
112
- t . equal ( deets [ 0 ] , NPM_PATH , 'spawn got the right path to npm' )
113
111
t . deepEqual ( deets [ 1 ] , [
112
+ NPM_PATH ,
114
113
'install' , 'installme@latest' , 'file:foo' ,
115
114
'--global' ,
116
115
'--prefix' , 'myprefix' ,
@@ -161,12 +160,12 @@ test('getNpmCache', t => {
161
160
}
162
161
} ) . _getNpmCache
163
162
return getCache ( { npm : NPM_PATH } ) . then ( cache => {
164
- t . equal ( cache , `${ NPM_PATH } config get cache --parseable` , 'requests cache from npm' )
163
+ t . equal ( cache , `${ process . argv [ 0 ] } ${ NPM_PATH } config get cache --parseable` , 'requests cache from npm' )
165
164
return getCache ( { npm : NPM_PATH , userconfig} )
166
165
} ) . then ( cache => {
167
166
t . equal (
168
167
cache ,
169
- `${ NPM_PATH } config get cache --parseable --userconfig ${
168
+ `${ process . argv [ 0 ] } ${ NPM_PATH } config get cache --parseable --userconfig ${
170
169
userconfig
171
170
} -escaped-as-path-true`,
172
171
'added userconfig if option present'
0 commit comments