/
githubmirror
/
nativefier
Обзор
Документация
Войти
/
githubmirror
/
nativefier
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
master
app/src/helpers/inferFlash.ts
90 строк
2 KB
Adam Weeden
Add playwright integration testing to the app (PR #1397)
21 апр 2022, 05:03
Не верифицирован
21 апр 2022, 05:03
e664bc6
Код
Авторство
О чём код?
import * as fs from 'fs'; import * as path from 'path'; import { isOSX, isWindows, isLinux } from './helpers'; import * as log from './loggingHelper'; type fsError = Error & { code: string }; /** * Find a file or directory */ function findSync( pattern: RegExp, basePath: string, limitSearchToDirectories = false, ): string[] { const matches: string[] = []; (function findSyncRecurse(base): void { let children: string[]; try { children = fs.readdirSync(base); } catch (err: unknown) { if ((err as fsError).code === 'ENOENT') { return; } throw err; } for (const child of children) { const childPath = path.join(base, child); const childIsDirectory = fs.lstatSync(childPath).isDirectory(); const patternMatches = pattern.test(childPath); if (!patternMatches) { if (!childIsDirectory) { return; } findSyncRecurse(childPath); return; } if (!limitSearchToDirectories) { matches.push(childPath); return; } if (childIsDirectory) { matches.push(childPath); } } })(basePath); return matches; } function findFlashOnLinux(): string { return findSync(/libpepflashplayer\.so/, '/opt/google/chrome')[0]; } function findFlashOnWindows(): string { return findSync( /pepflashplayer\.dll/, 'C:\\Program Files (x86)\\Google\\Chrome', )[0]; } function findFlashOnMac(): string { return findSync( /PepperFlashPlayer.plugin/, '/Applications/Google Chrome.app/', true, )[0]; } export function inferFlashPath(): string | undefined { if (isOSX()) { return findFlashOnMac(); } if (isWindows()) { return findFlashOnWindows(); } if (isLinux()) { return findFlashOnLinux(); } log.warn('Unable to determine OS to infer flash player'); return undefined; }