Skip to content

Commit

Permalink
Remove unnecessary Promise
Browse files Browse the repository at this point in the history
  • Loading branch information
dennisameling committed Feb 18, 2021
1 parent d049ede commit 1a3b434
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 31 deletions.
18 changes: 5 additions & 13 deletions dist/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

24 changes: 7 additions & 17 deletions src/downloader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,23 +10,13 @@ const gitForWindowsUsrBinPath = 'C:/Program Files/Git/usr/bin'
const gitForWindowsMINGW64BinPath = 'C:/Program Files/Git/mingw64/bin'

async function fetchJSONFromURL<T>(url: string): Promise<T> {
return new Promise<T>(async (resolve, reject) => {
try {
const res = await fetch(url)
if (res.status !== 200) {
reject(
new Error(
`Got code ${res.status}, URL: ${url}, message: ${res.statusText}`
)
)
return
}

resolve(res.json())
} catch (e) {
reject(e)
}
})
const res = await fetch(url)
if (res.status !== 200) {
throw new Error(
`Got code ${res.status}, URL: ${url}, message: ${res.statusText}`
)
}
return res.json()
}

function mkdirp(directoryPath: string): void {
Expand Down

0 comments on commit 1a3b434

Please sign in to comment.