Skip to content

Commit 2ad385c

Browse files
authored
Replace use of typed-rest-client with @actions/http-client (#634)
Fixes #630
1 parent 95dcf96 commit 2ad385c

File tree

4 files changed

+22
-65
lines changed

4 files changed

+22
-65
lines changed

sources/package-lock.json

Lines changed: 6 additions & 60 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

sources/package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@
4444
"cheerio": "1.0.0",
4545
"semver": "7.7.1",
4646
"string-argv": "0.3.2",
47-
"typed-rest-client": "2.1.0",
4847
"unhomoglyph": "1.0.6",
4948
"which": "5.0.0"
5049
},

sources/src/develocity/short-lived-token.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import * as httpm from 'typed-rest-client/HttpClient'
21
import * as core from '@actions/core'
2+
import * as httpm from '@actions/http-client'
33
import {BuildScanConfig} from '../configuration'
44
import {recordDeprecation} from '../deprecation-collector'
55

sources/src/wrapper-validation/checksums.ts

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import * as httpm from 'typed-rest-client/HttpClient'
21
import * as cheerio from 'cheerio'
32
import * as core from '@actions/core'
3+
import * as httpm from '@actions/http-client'
44

55
import fileWrapperChecksums from './wrapper-checksums.json'
66

@@ -69,8 +69,20 @@ async function httpGetJsonArray(url: string): Promise<unknown[]> {
6969
}
7070

7171
async function httpGetText(url: string): Promise<string> {
72-
const response = await httpc.get(url)
73-
return await response.readBody()
72+
const maxAttempts = 4
73+
let attempts = 0
74+
while (attempts < maxAttempts) {
75+
try {
76+
const response = await httpc.get(url)
77+
return await response.readBody()
78+
} catch (error) {
79+
attempts++
80+
if (attempts === maxAttempts) {
81+
return new Promise((_resolve, reject) => reject(error))
82+
}
83+
}
84+
}
85+
return new Promise((_resolve, reject) => reject(new Error('Illegal state')))
7486
}
7587

7688
async function addDistributionSnapshotChecksumUrls(checksumUrls: [string, string][]): Promise<void> {

0 commit comments

Comments
 (0)