@@ -87,7 +87,7 @@ async function getNode(versionSpec: string, checkLatest: boolean, nodejsMirror:
8787 version = await queryLatestMatch ( versionSpec , 'x64' , nodejsMirror ) ;
8888 installedArch = 'x64' ;
8989 }
90-
90+
9191 if ( ! version ) {
9292 throw new Error ( taskLib . loc ( 'NodeVersionNotFound' , versionSpec , osPlat , installedArch ) ) ;
9393 }
@@ -131,7 +131,12 @@ async function queryLatestMatch(versionSpec: string, installedArch: string, node
131131 let dataUrl = nodejsMirror + "/index.json" ;
132132 let rest : restm . RestClient = new restm . RestClient ( 'vsts-node-tool' ) ;
133133 let nodeVersions : INodeVersion [ ] = ( await rest . get < INodeVersion [ ] > ( dataUrl ) ) . result ;
134- nodeVersions . forEach ( ( nodeVersion :INodeVersion ) => {
134+ if ( ! nodeVersions ) {
135+ // this will be handled by the caller and an error will be thrown
136+ return null ;
137+ }
138+
139+ nodeVersions . forEach ( ( nodeVersion : INodeVersion ) => {
135140 // ensure this version supports your os and platform
136141 if ( nodeVersion . files . indexOf ( dataFileName ) >= 0 ) {
137142 // versions in the file are prefixed with 'v', which is not valid SemVer
@@ -149,7 +154,7 @@ async function queryLatestMatch(versionSpec: string, installedArch: string, node
149154 return nodeVersions . find ( v => v . semanticVersion === latestVersion ) . version ;
150155}
151156
152- async function acquireNode ( version : string , installedArch : string , nodejsMirror : string , retryCountOnDownloadFails : number , delayBetweenRetries : number ) : Promise < string > {
157+ async function acquireNode ( version : string , installedArch : string , nodejsMirror : string , retryCountOnDownloadFails : number , delayBetweenRetries : number ) : Promise < string > {
153158 //
154159 // Download - a tool installer intimately knows how to get the tool (and construct urls)
155160 //
@@ -230,14 +235,13 @@ async function acquireNodeFromFallbackLocation(version: string, nodejsMirror: st
230235 try {
231236 exeUrl = `${ nodejsMirror } /v${ version } /win-${ osArch } /node.exe` ;
232237 libUrl = `${ nodejsMirror } /v${ version } /win-${ osArch } /node.lib` ;
233-
238+
234239 await toolLib . downloadToolWithRetries ( exeUrl , path . join ( tempDir , "node.exe" ) , null , null , retryCountOnDownloadFails , delayBetweenRetries ) ;
235240 await toolLib . downloadToolWithRetries ( libUrl , path . join ( tempDir , "node.lib" ) , null , null , retryCountOnDownloadFails , delayBetweenRetries ) ;
236241 }
237242 catch ( err ) {
238- if ( err [ 'httpStatusCode' ] &&
239- err [ 'httpStatusCode' ] == 404 )
240- {
243+ if ( err [ 'httpStatusCode' ] &&
244+ err [ 'httpStatusCode' ] == 404 ) {
241245 exeUrl = `${ nodejsMirror } /v${ version } /node.exe` ;
242246 libUrl = `${ nodejsMirror } /v${ version } /node.lib` ;
243247
@@ -254,9 +258,9 @@ async function acquireNodeFromFallbackLocation(version: string, nodejsMirror: st
254258// Check is the system are darwin arm and rosetta is installed
255259function isDarwinArm ( osPlat : string , installedArch : string ) : boolean {
256260 if ( osPlat === 'darwin' && installedArch === 'arm64' ) {
257- // Check that Rosetta is installed and returns some pid
258- const execResult = taskLib . execSync ( 'pgrep' , 'oahd' ) ;
259- return execResult . code === 0 && ! ! execResult . stdout ;
261+ // Check that Rosetta is installed and returns some pid
262+ const execResult = taskLib . execSync ( 'pgrep' , 'oahd' ) ;
263+ return execResult . code === 0 && ! ! execResult . stdout ;
260264 }
261265 return false ;
262266}
0 commit comments