Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
async function downloadOrLocatePreferredBrowserRevision() {
const browserFetcher = puppeteer.createBrowserFetcher();
const preferredRevision = puppeteer._launcher._preferredRevision;
const localRevisions = await browserFetcher.localRevisions();
let revisionInfo;
if (localRevisions.includes(preferredRevision)) {
revisionInfo = await browserFetcher.revisionInfo(preferredRevision);
} else {
console.log(`Downloading Chromium ${preferredRevision}`);
revisionInfo = await browserFetcher.download(preferredRevision);
}
return puppeteer.launch({
executablePath: revisionInfo.executablePath
});
}