Skip to content

Commit 2e8fc6d

Browse files
dennisamelingdscho
authored andcommitted
Remove unnecessary Promise
1 parent a54551d commit 2e8fc6d

File tree

1 file changed

+7
-17
lines changed

1 file changed

+7
-17
lines changed

src/downloader.ts

Lines changed: 7 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -10,23 +10,13 @@ const gitForWindowsUsrBinPath = 'C:/Program Files/Git/usr/bin'
1010
const gitForWindowsMINGW64BinPath = 'C:/Program Files/Git/mingw64/bin'
1111

1212
async function fetchJSONFromURL<T>(url: string): Promise<T> {
13-
return new Promise<T>(async (resolve, reject) => {
14-
try {
15-
const res = await fetch(url)
16-
if (res.status !== 200) {
17-
reject(
18-
new Error(
19-
`Got code ${res.status}, URL: ${url}, message: ${res.statusText}`
20-
)
21-
)
22-
return
23-
}
24-
25-
resolve(res.json())
26-
} catch (e) {
27-
reject(e)
28-
}
29-
})
13+
const res = await fetch(url)
14+
if (res.status !== 200) {
15+
throw new Error(
16+
`Got code ${res.status}, URL: ${url}, message: ${res.statusText}`
17+
)
18+
}
19+
return res.json()
3020
}
3121

3222
function mkdirp(directoryPath: string): void {

0 commit comments

Comments
 (0)