@@ -42,7 +42,7 @@ if (!tempDirectory) {
4242 }
4343 tempDirectory = path . join ( baseLocation , 'actions' , 'temp' ) ;
4444}
45- function getNode ( versionSpec ) {
45+ function getNode ( versionSpec , mirror ) {
4646 return __awaiter ( this , void 0 , void 0 , function * ( ) {
4747 // check cache
4848 let toolPath ;
@@ -58,7 +58,7 @@ function getNode(versionSpec) {
5858 }
5959 else {
6060 // query nodejs.org for a matching version
61- version = yield queryLatestMatch ( versionSpec ) ;
61+ version = yield queryLatestMatch ( versionSpec , mirror ) ;
6262 if ( ! version ) {
6363 throw new Error ( `Unable to find Node version '${ versionSpec } ' for platform ${ osPlat } and architecture ${ osArch } .` ) ;
6464 }
@@ -67,7 +67,7 @@ function getNode(versionSpec) {
6767 }
6868 if ( ! toolPath ) {
6969 // download, extract, cache
70- toolPath = yield acquireNode ( version ) ;
70+ toolPath = yield acquireNode ( version , mirror ) ;
7171 }
7272 }
7373 //
@@ -84,7 +84,7 @@ function getNode(versionSpec) {
8484 } ) ;
8585}
8686exports . getNode = getNode ;
87- function queryLatestMatch ( versionSpec ) {
87+ function queryLatestMatch ( versionSpec , mirror ) {
8888 return __awaiter ( this , void 0 , void 0 , function * ( ) {
8989 // node offers a json list of versions
9090 let dataFileName ;
@@ -102,7 +102,7 @@ function queryLatestMatch(versionSpec) {
102102 throw new Error ( `Unexpected OS '${ osPlat } '` ) ;
103103 }
104104 let versions = [ ] ;
105- let dataUrl = 'https://nodejs.org/dist/ index.json' ;
105+ let dataUrl = ` ${ mirror } / index.json` ;
106106 let rest = new restm . RestClient ( 'setup-node' ) ;
107107 let nodeVersions = ( yield rest . get ( dataUrl ) ) . result || [ ] ;
108108 nodeVersions . forEach ( ( nodeVersion ) => {
@@ -142,7 +142,7 @@ function evaluateVersions(versions, versionSpec) {
142142 }
143143 return version ;
144144}
145- function acquireNode ( version ) {
145+ function acquireNode ( version , mirror ) {
146146 return __awaiter ( this , void 0 , void 0 , function * ( ) {
147147 //
148148 // Download - a tool installer intimately knows how to get the tool (and construct urls)
@@ -152,14 +152,14 @@ function acquireNode(version) {
152152 ? 'node-v' + version + '-win-' + os . arch ( )
153153 : 'node-v' + version + '-' + osPlat + '-' + os . arch ( ) ;
154154 let urlFileName = osPlat == 'win32' ? fileName + '.7z' : fileName + '.tar.gz' ;
155- let downloadUrl = 'https://nodejs.org/dist/v' + version + '/' + urlFileName ;
155+ let downloadUrl = ` ${ mirror } /v` + version + '/' + urlFileName ;
156156 let downloadPath ;
157157 try {
158158 downloadPath = yield tc . downloadTool ( downloadUrl ) ;
159159 }
160160 catch ( err ) {
161161 if ( err instanceof tc . HTTPError && err . httpStatusCode == 404 ) {
162- return yield acquireNodeFromFallbackLocation ( version ) ;
162+ return yield acquireNodeFromFallbackLocation ( version , mirror ) ;
163163 }
164164 throw err ;
165165 }
@@ -193,7 +193,7 @@ function acquireNode(version) {
193193// This method attempts to download and cache the resources from these alternative locations.
194194// Note also that the files are normally zipped but in this case they are just an exe
195195// and lib file in a folder, not zipped.
196- function acquireNodeFromFallbackLocation ( version ) {
196+ function acquireNodeFromFallbackLocation ( version , mirror ) {
197197 return __awaiter ( this , void 0 , void 0 , function * ( ) {
198198 // Create temporary folder to download in to
199199 let tempDownloadFolder = 'temp_' + Math . floor ( Math . random ( ) * 2000000000 ) ;
@@ -202,17 +202,17 @@ function acquireNodeFromFallbackLocation(version) {
202202 let exeUrl ;
203203 let libUrl ;
204204 try {
205- exeUrl = `https://nodejs.org/dist /v${ version } /win-${ os . arch ( ) } /node.exe` ;
206- libUrl = `https://nodejs.org/dist /v${ version } /win-${ os . arch ( ) } /node.lib` ;
205+ exeUrl = `${ mirror } /v${ version } /win-${ os . arch ( ) } /node.exe` ;
206+ libUrl = `${ mirror } /v${ version } /win-${ os . arch ( ) } /node.lib` ;
207207 const exePath = yield tc . downloadTool ( exeUrl ) ;
208208 yield io . cp ( exePath , path . join ( tempDir , 'node.exe' ) ) ;
209209 const libPath = yield tc . downloadTool ( libUrl ) ;
210210 yield io . cp ( libPath , path . join ( tempDir , 'node.lib' ) ) ;
211211 }
212212 catch ( err ) {
213213 if ( err instanceof tc . HTTPError && err . httpStatusCode == 404 ) {
214- exeUrl = `https://nodejs.org/dist /v${ version } /node.exe` ;
215- libUrl = `https://nodejs.org/dist /v${ version } /node.lib` ;
214+ exeUrl = `${ mirror } /v${ version } /node.exe` ;
215+ libUrl = `${ mirror } /v${ version } /node.lib` ;
216216 const exePath = yield tc . downloadTool ( exeUrl ) ;
217217 yield io . cp ( exePath , path . join ( tempDir , 'node.exe' ) ) ;
218218 const libPath = yield tc . downloadTool ( libUrl ) ;
0 commit comments