Skip to content

Commit

Permalink
✨ Expose used chrome versions (#279)
Browse files Browse the repository at this point in the history
* expose chrome versions

* chromeRevisions -> chromiumRevisions

* chromiumRevisions -> chromium.revisions
  • Loading branch information
olebedev authored Apr 6, 2021
1 parent 752b5cd commit 9400c51
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 14 deletions.
16 changes: 10 additions & 6 deletions packages/core/src/install.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,13 @@ import https from 'https';
import logger from '@percy/logger';
import readableBytes from './utils/bytes';

const revisions = {
linux: '812847',
win64: '812845',
win32: '812822',
darwin: '812851'
};

// Returns an item from the map keyed by the current platform
function selectByPlatform(map) {
let { platform, arch } = process;
Expand All @@ -15,12 +22,7 @@ function installChromium({
// default directory is within @percy/core package root
directory = path.resolve(__dirname, '../.local-chromium'),
// default revision corresponds to v87.0.4280.x
revision = selectByPlatform({
linux: '812847',
win64: '812845',
win32: '812822',
darwin: '812851'
})
revision = selectByPlatform(revisions),
} = {}) {
let extract = (i, o) => require('extract-zip')(i, { dir: o });

Expand Down Expand Up @@ -49,6 +51,8 @@ function installChromium({
});
}

installChromium.revisions = revisions;

// Installs an executable from a url to a local directory, returning the full path to the extracted
// binary. Skips installation if the executable already exists at the binary path.
async function install({
Expand Down
16 changes: 8 additions & 8 deletions packages/core/test/unit/install.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -155,23 +155,23 @@ describe('Unit / Install', () => {

for (let [platform, expected] of Object.entries({
linux: {
revision: '812847',
url: jasmine.stringMatching('Linux_x64/812847/chrome-linux.zip'),
revision: install.chromium.revisions.linux,
url: jasmine.stringMatching(`Linux_x64/${install.chromium.revisions.linux}/chrome-linux.zip`),
return: path.join('chrome-linux', 'chrome')
},
darwin: {
revision: '812851',
url: jasmine.stringMatching('Mac/812851/chrome-mac.zip'),
revision: install.chromium.revisions.darwin,
url: jasmine.stringMatching(`Mac/${install.chromium.revisions.darwin}/chrome-mac.zip`),
return: path.join('chrome-mac', 'Chromium.app', 'Contents', 'MacOS', 'Chromium')
},
win64: {
revision: '812845',
url: jasmine.stringMatching('Win_x64/812845/chrome-win.zip'),
revision: install.chromium.revisions.win64,
url: jasmine.stringMatching(`Win_x64/${install.chromium.revisions.win64}/chrome-win.zip`),
return: path.join('chrome-win', 'chrome.exe')
},
win32: {
revision: '812822',
url: jasmine.stringMatching('Win/812822/chrome-win32.zip'),
revision: install.chromium.revisions.win32,
url: jasmine.stringMatching(`Win/${install.chromium.revisions.win32}/chrome-win32.zip`),
return: path.join('chrome-win32', 'chrome.exe')
}
})) {
Expand Down

0 comments on commit 9400c51

Please sign in to comment.