Skip to content

Commit

Permalink
When download failed, throw message with details of what exactly failed
Browse files Browse the repository at this point in the history
  • Loading branch information
Envek committed May 20, 2021
1 parent 2c38489 commit c7b3bbb
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions .npm/postinstall.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,13 +62,11 @@ async function downloadBinary() {
fileName,
retry: { maxRetries: 5, delay: 50 },
})
dl.on("end", () => console.log("lefthook binary was downloaded"))
try {
await dl.start()
} catch(e) {
console.error(`Failed to download ${fileName} while fetching ${downloadURL}`)
dl.on("error", (e) => {
e.message = `Failed to download ${fileName}: ${e.message} while fetching ${downloadURL}`
throw e
}
})
await dl.start()
return path.join(binDir, fileName)
}

Expand Down

0 comments on commit c7b3bbb

Please sign in to comment.