@@ -192,6 +192,7 @@ export interface INodeBinaryProvider {
192
192
env : EnvironmentVars ,
193
193
executable ?: string ,
194
194
explicitVersion ?: number ,
195
+ cwd ?: string ,
195
196
) : Promise < NodeBinary > ;
196
197
}
197
198
@@ -221,9 +222,10 @@ export class NodeBinaryProvider {
221
222
env : EnvironmentVars ,
222
223
executable = 'node' ,
223
224
explicitVersion ?: number ,
225
+ cwd ?: string ,
224
226
) : Promise < NodeBinary > {
225
227
try {
226
- return await this . resolveAndValidateInner ( env , executable , explicitVersion ) ;
228
+ return await this . resolveAndValidateInner ( env , executable , explicitVersion , cwd ) ;
227
229
} catch ( e ) {
228
230
if ( ! ( e instanceof NodeBinaryOutOfDateError ) ) {
229
231
throw e ;
@@ -249,6 +251,7 @@ export class NodeBinaryProvider {
249
251
env : EnvironmentVars ,
250
252
executable : string ,
251
253
explicitVersion : number | undefined ,
254
+ cwd : string | undefined ,
252
255
) : Promise < NodeBinary > {
253
256
const location = await this . resolveBinaryLocation ( executable , env ) ;
254
257
this . logger . info ( LogTag . RuntimeLaunch , 'Using binary at' , { location, executable } ) ;
@@ -278,7 +281,7 @@ export class NodeBinaryProvider {
278
281
}
279
282
280
283
try {
281
- const realBinary = await this . resolveAndValidateInner ( env , 'node' , undefined ) ;
284
+ const realBinary = await this . resolveAndValidateInner ( env , 'node' , undefined , cwd ) ;
282
285
return new NodeBinary ( location , realBinary . version ) ;
283
286
} catch ( e ) {
284
287
// if we verified it's outdated, still throw the error. If it's not
@@ -303,7 +306,7 @@ export class NodeBinaryProvider {
303
306
}
304
307
305
308
// match the "12" in "v12.34.56"
306
- const versionText = await this . getVersionText ( location ) ;
309
+ const versionText = await this . getVersionText ( location , cwd ) ;
307
310
308
311
// Handle other cases where Node.js is installed via snap, but not in `/span/`.
309
312
// We just get empty output from it in that case.
@@ -345,10 +348,11 @@ export class NodeBinaryProvider {
345
348
: await findInPath ( this . fs , executable , env . value ) ;
346
349
}
347
350
348
- public async getVersionText ( binary : string ) {
351
+ public async getVersionText ( binary : string , cwd : string | undefined ) {
349
352
try {
350
353
const { stdout } = await spawnAsync ( binary , [ '--version' ] , {
351
354
env : EnvironmentVars . processEnv ( ) . defined ( ) ,
355
+ cwd,
352
356
} ) ;
353
357
return stdout . trim ( ) ;
354
358
} catch ( e ) {
0 commit comments