Skip to content

Commit

Permalink
upstream.js: strengthen error handling & logs
Browse files Browse the repository at this point in the history
  • Loading branch information
quentin-st committed Mar 29, 2022
1 parent e980b92 commit 348abd4
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions tools/lib/upstream.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ const getMeta = async (version, flavour = 'default') => {
};

const download = async (url, destPath) => {
console.log('Downloading ' + url + ' to ' + destPath);
return new Promise((resolve, reject) => {
request(url)
.on('error', () => reject())
Expand Down Expand Up @@ -89,13 +90,17 @@ const extractZip = async (zipPath, destDir, filePattern) => {
// Extract ZIP
return new Promise((resolve, reject) => {
yauzl.open(zipPath, (err, zipfile) => {
if (err) throw err;
if (err) {
reject(err);
}

zipfile
.on('entry', (entry) => {
if (filePattern.test(entry.fileName)) {
zipfile.openReadStream(entry, function (err, readStream) {
if (err) throw err;
if (err) {
reject(err);
}

readStream.pipe(fs.createWriteStream(`${destDir}/${path.basename(entry.fileName)}`));
});
Expand Down

0 comments on commit 348abd4

Please sign in to comment.