File tree Expand file tree Collapse file tree 1 file changed +23
-12
lines changed
Expand file tree Collapse file tree 1 file changed +23
-12
lines changed Original file line number Diff line number Diff line change @@ -12,21 +12,32 @@ function createNpmrcFile {
1212 New-Item - Path . - Name .npmrc - ItemType File - Value " registry=$registry `n " - Force
1313}
1414
15- try {
16- Write-Host " Checking if adsk npm registry is reachable..." - ForegroundColor Blue
17- $response = Invoke-WebRequest - Uri $adskNpmRegistry - TimeoutSec 20 - ErrorAction Stop
18-
19- if ($response.StatusCode -eq 200 ) {
20- Write-Host " adsk npm registry is reachable" - ForegroundColor Green
21- createNpmrcFile - registry $adskNpmRegistry
22- Write-Output " //npm.autodesk.com/artifactory/api/npm/:_authToken=`$ {NPM_TOKEN}" | Out-File - FilePath .npmrc - Encoding UTF8 - Append
15+ function Test-UrlReachable {
16+ param ([string ]$url )
17+ $response = $null
18+ try {
19+ $request = [System.Net.WebRequest ]::Create($url )
20+ $request.Method = " HEAD"
21+ $request.Timeout = 20000 # 20 seconds
22+ $response = $request.GetResponse ()
23+ return $true
24+ }
25+ catch {
26+ return $false
2327 }
24- else {
25- Write-Host " adsk npm registry is not reachable" - ForegroundColor Red
26- createNpmrcFile - registry $npmRegistry
28+ finally {
29+ if ($response ) { $response.Dispose () }
2730 }
2831}
29- catch {
32+
33+ Write-Host " Checking if adsk npm registry is reachable..." - ForegroundColor Blue
34+
35+ if (Test-UrlReachable - url $adskNpmRegistry ) {
36+ Write-Host " adsk npm registry is reachable" - ForegroundColor Green
37+ createNpmrcFile - registry $adskNpmRegistry
38+ Write-Output " //npm.autodesk.com/artifactory/api/npm/:_authToken=`$ {NPM_TOKEN}" | Out-File - FilePath .npmrc - Encoding UTF8 - Append
39+ }
40+ else {
3041 Write-Host " adsk npm registry is not reachable" - ForegroundColor Red
3142 createNpmrcFile - registry $npmRegistry
3243}
You can’t perform that action at this time.
0 commit comments