UNPKG

devtools

Version:

A Chrome DevTools protocol binding that maps WebDriver commands into Chrome DevTools commands using Puppeteer

24 lines (23 loc) 932 B
import path from 'node:path'; import { execSync } from 'node:child_process'; import { canAccess } from '@wdio/utils/node'; const DARWIN_LIST_APPS = 'system_profiler SPApplicationsDataType -json'; export const darwinGetAppPaths = (app) => { const apps = JSON.parse(execSync(DARWIN_LIST_APPS).toString()); const appPaths = apps.SPApplicationsDataType .filter(inst => inst.info && inst.info.startsWith(app)) .map(inst => inst.path); return appPaths; }; export const darwinGetInstallations = (appPaths, suffixes) => { const installations = []; appPaths.forEach((inst) => { suffixes.forEach(suffix => { const execPath = path.join(inst.substring(0, inst.indexOf('.app') + 4).trim(), suffix); if (canAccess(execPath) && installations.indexOf(execPath) === -1) { installations.push(execPath); } }); }); return installations; };