From 80bf6eb7ede23f69cd3320d90253f7d4acdb8a5a Mon Sep 17 00:00:00 2001 From: yoavain-sundaysky Date: Wed, 8 Dec 2021 12:58:03 +0200 Subject: [PATCH] Fix https://github.com/markgardner/node-flywaydb/issues/34 extract-zip: Replace callback-style API with promise-style API --- lib/download.js | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/lib/download.js b/lib/download.js index 2369337..f76594e 100644 --- a/lib/download.js +++ b/lib/download.js @@ -201,17 +201,14 @@ function downloadMaven(libDir, groupId, artifactId, version, downloadExpirationT fs.mkdirSync(extractDir); if(fileExt === '.zip') { - return new Promise(function(res, rej) { - extractZip(file, { dir: extractDir }, function(err) { - if(err) { - rimraf.sync(extractDir); - - rej(err); - } else { - res({ version, type, dir: extractDir }); - } + return extractZip(file, { dir: extractDir }) + .then(function () { + return { version, type, dir: extractDir }; + }) + .catch(function (err) { + rimraf.sync(extractDir); + throw err; }); - }); } else { return new Promise(function(res, rej) { spawn('tar', ['zxf', file], {