Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
static async getChromeExecutablePath(stable) {
if (!stable) {
const launcher = importCwd.silent('puppeteer');
if (!launcher) {
throw new Error(
'Cannot find Chromium. Make sure you have puppeteer installed',
);
}
const exePath = launcher.executablePath();
return exePath;
}
const installations = await chromeFinder[getPlatform()]();
if (installations.length === 0) {
throw new Error('Chrome not installed');
}
return installations.pop(); // If you have multiple installed chromes return regular chrome
}
static async getChromeExecutablePath(stable) {
if (!stable) {
const launcher = importCwd.silent('puppeteer');
if (!launcher) {
throw new Error(
'Cannot find Chromium. Make sure you have puppeteer installed',
);
}
const exePath = launcher.executablePath();
return exePath;
}
const installations = await chromeFinder[getPlatform()]();
if (installations.length === 0) {
throw new Error('Chrome not installed');
}
return installations.pop(); // If you have multiple installed chromes return regular chrome
}
export const findChrome = () => {
if (!chromePath) {
try {
const platform = getPlatform()
const [path] = chromeFinder[platform as 'darwin' | 'linux' | 'win32' | 'wsl']()
if (!is.string(path)) {
throw new Error()
}
chromePath = path
} catch (error) {
throw new Error(
'Could not find a Chrome installation. If you have already installed Chrome, set the CHROME_PATH environment variable.'
)
}
}
return chromePath
}