Skip to content

Commit 1a3b434

Browse files
committed
Remove unnecessary Promise
1 parent d049ede commit 1a3b434

File tree

3 files changed

+13
-31
lines changed

3 files changed

+13
-31
lines changed

dist/index.js

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

dist/index.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

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)