@@ -119,22 +119,6 @@ export async function installVersion(installTarget: string, locator: Locator, {s
119
119
sendTo . on ( `finish` , resolve ) ;
120
120
} ) ;
121
121
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
-
138
122
await fs . promises . mkdir ( path . dirname ( installFolder ) , { recursive : true } ) ;
139
123
await fs . promises . rename ( tmpFolder , installFolder ) ;
140
124
@@ -143,8 +127,21 @@ export async function installVersion(installTarget: string, locator: Locator, {s
143
127
} ) ;
144
128
}
145
129
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` ) ;
148
145
149
146
return new Promise < number > ( ( resolve , reject ) => {
150
147
process . on ( `SIGINT` , ( ) => {
@@ -162,7 +159,7 @@ export async function runVersion(installTarget: string, locator: Locator, binNam
162
159
if ( context . stderr === process . stderr )
163
160
stdio [ 2 ] = `inherit` ;
164
161
165
- const sub = spawn ( process . execPath , [ binPath , ...args ] , {
162
+ const sub = spawn ( process . execPath , [ binPath ! , ...args ] , {
166
163
cwd : context . cwd ,
167
164
stdio,
168
165
} ) ;
0 commit comments