@@ -87,7 +87,7 @@ async function getNode(versionSpec: string, checkLatest: boolean, nodejsMirror:
87
87
version = await queryLatestMatch ( versionSpec , 'x64' , nodejsMirror ) ;
88
88
installedArch = 'x64' ;
89
89
}
90
-
90
+
91
91
if ( ! version ) {
92
92
throw new Error ( taskLib . loc ( 'NodeVersionNotFound' , versionSpec , osPlat , installedArch ) ) ;
93
93
}
@@ -131,7 +131,12 @@ async function queryLatestMatch(versionSpec: string, installedArch: string, node
131
131
let dataUrl = nodejsMirror + "/index.json" ;
132
132
let rest : restm . RestClient = new restm . RestClient ( 'vsts-node-tool' ) ;
133
133
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 ) => {
135
140
// ensure this version supports your os and platform
136
141
if ( nodeVersion . files . indexOf ( dataFileName ) >= 0 ) {
137
142
// 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
149
154
return nodeVersions . find ( v => v . semanticVersion === latestVersion ) . version ;
150
155
}
151
156
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 > {
153
158
//
154
159
// Download - a tool installer intimately knows how to get the tool (and construct urls)
155
160
//
@@ -230,14 +235,13 @@ async function acquireNodeFromFallbackLocation(version: string, nodejsMirror: st
230
235
try {
231
236
exeUrl = `${ nodejsMirror } /v${ version } /win-${ osArch } /node.exe` ;
232
237
libUrl = `${ nodejsMirror } /v${ version } /win-${ osArch } /node.lib` ;
233
-
238
+
234
239
await toolLib . downloadToolWithRetries ( exeUrl , path . join ( tempDir , "node.exe" ) , null , null , retryCountOnDownloadFails , delayBetweenRetries ) ;
235
240
await toolLib . downloadToolWithRetries ( libUrl , path . join ( tempDir , "node.lib" ) , null , null , retryCountOnDownloadFails , delayBetweenRetries ) ;
236
241
}
237
242
catch ( err ) {
238
- if ( err [ 'httpStatusCode' ] &&
239
- err [ 'httpStatusCode' ] == 404 )
240
- {
243
+ if ( err [ 'httpStatusCode' ] &&
244
+ err [ 'httpStatusCode' ] == 404 ) {
241
245
exeUrl = `${ nodejsMirror } /v${ version } /node.exe` ;
242
246
libUrl = `${ nodejsMirror } /v${ version } /node.lib` ;
243
247
@@ -254,9 +258,9 @@ async function acquireNodeFromFallbackLocation(version: string, nodejsMirror: st
254
258
// Check is the system are darwin arm and rosetta is installed
255
259
function isDarwinArm ( osPlat : string , installedArch : string ) : boolean {
256
260
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 ;
260
264
}
261
265
return false ;
262
266
}
0 commit comments