@@ -119,22 +119,6 @@ export async function installVersion(installTarget: string, locator: Locator, {s
119119 sendTo . on ( `finish` , resolve ) ;
120120 } ) ;
121121
122- await fs . promises . mkdir ( path . join ( tmpFolder , `.bin` ) ) ;
123-
124- if ( Array . isArray ( spec . bin ) ) {
125- if ( outputFile !== null ) {
126- for ( const name of spec . bin ) {
127- await fsUtils . makeShim ( path . join ( tmpFolder , `.bin` , name ) , outputFile ) ;
128- }
129- } else {
130- throw new Error ( `Assertion failed` ) ;
131- }
132- } else {
133- for ( const [ name , dest ] of Object . entries ( spec . bin ) ) {
134- fsUtils . makeShim ( path . join ( tmpFolder , `.bin` , name ) , path . join ( tmpFolder , dest ) ) ;
135- }
136- }
137-
138122 await fs . promises . mkdir ( path . dirname ( installFolder ) , { recursive : true } ) ;
139123 await fs . promises . rename ( tmpFolder , installFolder ) ;
140124
@@ -143,8 +127,21 @@ export async function installVersion(installTarget: string, locator: Locator, {s
143127 } ) ;
144128}
145129
146- export async function runVersion ( installTarget : string , locator : Locator , binName : string , args : Array < string > , context : Context ) {
147- const binPath = path . join ( installTarget , `.bin` , binName ) ;
130+ export async function runVersion ( installSpec : { location : string , spec : PackageManagerSpec } , locator : Locator , binName : string , args : Array < string > , context : Context ) {
131+ let binPath : string | null = null ;
132+ if ( Array . isArray ( installSpec . spec . bin ) ) {
133+ binPath = path . join ( installSpec . location , `${ binName } .js` ) ;
134+ } else {
135+ for ( const [ name , dest ] of Object . entries ( installSpec . spec . bin ) ) {
136+ if ( name === binName ) {
137+ binPath = path . join ( installSpec . location , dest ) ;
138+ break ;
139+ }
140+ }
141+ }
142+
143+ if ( ! binPath )
144+ throw new Error ( `Assertion failed: Unable to locate bin path` ) ;
148145
149146 return new Promise < number > ( ( resolve , reject ) => {
150147 process . on ( `SIGINT` , ( ) => {
@@ -162,7 +159,7 @@ export async function runVersion(installTarget: string, locator: Locator, binNam
162159 if ( context . stderr === process . stderr )
163160 stdio [ 2 ] = `inherit` ;
164161
165- const sub = spawn ( process . execPath , [ binPath , ...args ] , {
162+ const sub = spawn ( process . execPath , [ binPath ! , ...args ] , {
166163 cwd : context . cwd ,
167164 stdio,
168165 } ) ;
0 commit comments