From 487a134ea86da96c28c7ea7093b99b71f21b83d5 Mon Sep 17 00:00:00 2001 From: Pine Wu Date: Thu, 31 Oct 2019 14:26:58 -0700 Subject: [PATCH] Reject promise when https.get fails. Fix #49 --- lib/download.ts | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/lib/download.ts b/lib/download.ts index 2db221d..08f03c2 100644 --- a/lib/download.ts +++ b/lib/download.ts @@ -71,18 +71,20 @@ async function downloadVSCodeArchive(version: DownloadVersion): Promise outStream.on('close', () => { resolve(archivePath); }); + https.get(archiveRequestOptions, res => { res.pipe(outStream); - }); + }).on('error', e => reject(e)); } else { const zipPath = path.resolve(vscodeTestDir, `vscode-${version}.tgz`); const outStream = fs.createWriteStream(zipPath); - https.get(archiveRequestOptions, res => { - res.pipe(outStream); - }); outStream.on('close', () => { resolve(zipPath); }); + + https.get(archiveRequestOptions, res => { + res.pipe(outStream); + }).on('error', e => reject(e)); } }); });