@@ -10,10 +10,7 @@ const test = require('tap').test
1010const main = require ( '../index.js' )
1111
1212const 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' )
1714
1815test ( 'npx --shell-auto-fallback' , t => {
1916 return child . spawn ( 'node' , [
@@ -53,7 +50,9 @@ test('npx existing subcommand', {
5350 } )
5451} )
5552
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 => {
5756 let whichBin = path . resolve (
5857 __dirname , '..' , 'node_modules' , '.bin' , 'which'
5958 )
@@ -89,9 +88,9 @@ test('installPackages unit', t => {
8988 const installPkgs = requireInject ( '../index.js' , {
9089 '../child.js' : {
9190 spawn ( npmPath , args ) {
92- if ( args [ 1 ] === 'fail' ) {
91+ if ( args [ 2 ] === 'fail' ) {
9392 return Promise . reject ( new Error ( 'fail' ) )
94- } else if ( args [ 1 ] === 'codefail' ) {
93+ } else if ( args [ 2 ] === 'codefail' ) {
9594 const err = new Error ( 'npm failed' )
9695 err . exitCode = 123
9796 return Promise . reject ( err )
@@ -109,8 +108,8 @@ test('installPackages unit', t => {
109108 return installPkgs ( [ 'installme@latest' , 'file:foo' ] , 'myprefix' , {
110109 npm : NPM_PATH
111110 } ) . then ( deets => {
112- t . equal ( deets [ 0 ] , NPM_PATH , 'spawn got the right path to npm' )
113111 t . deepEqual ( deets [ 1 ] , [
112+ NPM_PATH ,
114113 'install' , 'installme@latest' , 'file:foo' ,
115114 '--global' ,
116115 '--prefix' , 'myprefix' ,
@@ -161,12 +160,12 @@ test('getNpmCache', t => {
161160 }
162161 } ) . _getNpmCache
163162 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' )
165164 return getCache ( { npm : NPM_PATH , userconfig} )
166165 } ) . then ( cache => {
167166 t . equal (
168167 cache ,
169- `${ NPM_PATH } config get cache --parseable --userconfig ${
168+ `${ process . argv [ 0 ] } ${ NPM_PATH } config get cache --parseable --userconfig ${
170169 userconfig
171170 } -escaped-as-path-true`,
172171 'added userconfig if option present'
0 commit comments