UNPKG

puppeteer-finder

Version:

Find a executable Chrome / Edge / Firefox in your system

53 lines 1.49 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.isExecutable = exports.canAccess = exports.sort = exports.newLineRegex = void 0; const fs_1 = __importDefault(require("fs")); exports.newLineRegex = /\r?\n/; function sort(installations, priorities) { const defaultPriority = 10; // assign priorities return installations .map((inst) => { for (const pair of priorities) { if (pair.regex.test(inst)) { return { path: inst, weight: pair.weight }; } } return { path: inst, weight: defaultPriority }; }) // sort based on priorities .sort((a, b) => b.weight - a.weight) // remove priority flag .map(pair => pair.path); } exports.sort = sort; function canAccess(file) { if (!file) { return false; } try { fs_1.default.accessSync(file); return true; } catch (e) { return false; } } exports.canAccess = canAccess; function isExecutable(file) { if (!file) { return false; } try { var stat = fs_1.default.statSync(file); return stat && typeof stat.isFile === 'function' && stat.isFile(); } catch (e) { return false; } } exports.isExecutable = isExecutable; //# sourceMappingURL=utils.js.map