From 75cba1903af9c070392752267f4e0abe2bf33844 Mon Sep 17 00:00:00 2001 From: Mike Grybyk Date: Wed, 25 Nov 2020 13:20:43 +0100 Subject: [PATCH] fix chromiumedge download on macos --- lib/default-config.js | 4 ++-- lib/install.js | 32 +++++++++++++------------------- 2 files changed, 15 insertions(+), 21 deletions(-) diff --git a/lib/default-config.js b/lib/default-config.js index 1559b154..60647c71 100644 --- a/lib/default-config.js +++ b/lib/default-config.js @@ -13,7 +13,7 @@ module.exports = { baseURL: 'https://selenium-release.storage.googleapis.com' }, firefox: { - version: '0.26.0', + version: '0.28.0', arch: process.arch, baseURL: 'https://github.com/mozilla/geckodriver/releases/download' }, @@ -21,7 +21,7 @@ module.exports = { version: '17134' }, chromiumedge: { - version: '86.0.600.0', + version: '86.0.622.69', arch: process.arch, baseURL: 'https://msedgedriver.azureedge.net' } diff --git a/lib/install.js b/lib/install.js index ec1f192d..95c64acb 100644 --- a/lib/install.js +++ b/lib/install.js @@ -444,10 +444,6 @@ function install(opts, cb) { debug("unzip " + zipFilePath); var yauzl = require("yauzl"); - var extractPath = path.join( - path.dirname(zipFilePath), - path.basename(zipFilePath, ".zip") - ); yauzl.open(zipFilePath, function onOpenZipFile(err, zipFile) { if (err) { @@ -458,7 +454,7 @@ function install(opts, cb) { if (/.*\/.*/.test(entry.fileName)) { return; // ignore folders, i.e. release notes folder in edge driver zip } - zipFile.openReadStream(entry, function onOpenZipFileEntryReadStream( + zipFile.openReadStream(entry, { autoClose: true }, function onOpenZipFileEntryReadStream( err, readStream ) { @@ -466,6 +462,10 @@ function install(opts, cb) { cb(err); return; } + var extractPath = path.join( + path.dirname(zipFilePath), + isBrowserDriver(entry.fileName) ? path.basename(zipFilePath, ".zip") : entry.fileName + ); var extractWriteStream = fs .createWriteStream(extractPath) .once( @@ -478,12 +478,11 @@ function install(opts, cb) { "error", cb.bind(null, new Error("Could not read " + zipFilePath)) ) - .once("finish", function onExtracted() { - zipFile.close(); - cb(); - }); }); }); + zipFile.on('close', () => { + cb(); + }) }); } @@ -580,16 +579,6 @@ function checksum(filepath, cb) { .once("error", cb); } -function unquote(str, quoteChar) { - quoteChar = quoteChar || '"'; - - if (str[0] === quoteChar && str[str.length - 1] === quoteChar) { - return str.slice(1, str.length - 1); - } - - return str; -} - function isUpToDate(url, requestOpts, hash, cb) { if (!hash) { return cb(null, false); @@ -626,3 +615,8 @@ function isUpToDate(url, requestOpts, hash, cb) { cb(new Error("Could not request headers from " + url + ": " + err)); }); } + +const isBrowserDriver = (fileName) => { + const extensions = [".exe"] + return extensions.some(ext => fileName.endsWith(ext)) || !fileName.includes(".") +}