Skip to content

Commit

Permalink
download chromium to a local dir
Browse files Browse the repository at this point in the history
  • Loading branch information
muodov committed Mar 23, 2023
1 parent 8451d39 commit 24f8060
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ node_modules
.vscode/
data/
summary.json
chromium/
14 changes: 9 additions & 5 deletions helpers/downloadCustomChromium.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
const path = require('path');
const puppeteer = require('puppeteer');
const ProgressBar = require('progress');
const chalk = require('chalk').default;
Expand All @@ -8,11 +9,14 @@ const chalk = require('chalk').default;
* @returns {Promise<string>} executable path of the downloaded Chromium
*/
async function downloadCustomChromium(log, version) {
/**
* @type {import('puppeteer').BrowserFetcher}
*/
// @ts-ignore for some reason createBrowserFetcher is missing from the typescript definition?
const browserFetcher = puppeteer.createBrowserFetcher();
const browserFetcher = puppeteer.createBrowserFetcher({
path: path.join(__dirname, '..', 'chromium'),
});
const revInfo = browserFetcher.revisionInfo(version);
if (revInfo.local) {
log(chalk.blue(`⬇ Using existing version of Chromium - ${version}.`));
return revInfo.executablePath;
}
const canDownload = await browserFetcher.canDownload(version);

if (!canDownload) {
Expand Down

0 comments on commit 24f8060

Please sign in to comment.