UNPKG

playwright-fluent

Version:
52 lines (51 loc) 2.42 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.getChromeCanaryPath = exports.getChromePath = void 0; const tslib_1 = require("tslib"); const os = tslib_1.__importStar(require("os")); const fs_1 = require("fs"); const which = tslib_1.__importStar(require("which")); const currentPlatformType = os.type(); const x86Path = 'C:/Program Files (x86)/Google/Chrome/Application/chrome.exe'; const x64Path = 'C:/Program Files/Google/Chrome/Application/chrome.exe'; function getChromePath() { switch (currentPlatformType) { case 'Darwin': return '/Applications/Google Chrome.app/Contents/MacOS/Google Chrome'; case 'Windows_NT': if ((0, fs_1.existsSync)(x64Path)) { return x64Path; } return x86Path; case 'Linux': if (which.sync('google-chrome-stable', { nothrow: true })) { return which.sync('google-chrome-stable'); } if (which.sync('google-chrome', { nothrow: true })) { return which.sync('google-chrome'); } if (which.sync('chromium-browser', { nothrow: true })) { return which.sync('chromium-browser'); } throw new Error('You should supply the path to the Chrome App in the launch options.'); default: throw new Error(`Platform '${currentPlatformType}' is not yet supported in playwright-fluent. You should supply the path to the Chrome App in the launch options.`); } } exports.getChromePath = getChromePath; function getChromeCanaryPath() { switch (currentPlatformType) { case 'Darwin': return '/Applications/Google Chrome Canary.app/Contents/MacOS/Google Chrome Canary'; case 'Windows_NT': return 'C:/Program Files (x86)/Google/Chrome SxS/Application/chrome.exe'; case 'Linux': if (which.sync('google-chrome-unstable', { nothrow: true })) { return which.sync('google-chrome-unstable'); } throw new Error('You should supply the path to the Chrome App in the launch options.'); default: throw new Error(`Platform '${currentPlatformType}' is not yet supported in playwright-fluent. You should supply the path to the Chrome Canary App in the launch options.`); } } exports.getChromeCanaryPath = getChromeCanaryPath;