// Le Chromium des bancs et du témoin des positions : `CHROMIUM` s'il est donné, sinon le plus récent du cache de Playwright // (~/.cache/ms-playwright/chromium-/). Le chemin écrit en dur (chromium-1254) a disparu à une mise à jour de Playwright // (constaté le 20/11, LOT Q-contour-dette) : le cas du témoin se sautait alors sans rien dire. import { existsSync, readdirSync } from 'node:fs'; import { homedir } from 'node:os'; import { join } from 'node:path'; export function chromium(): string { if (process.env.CHROMIUM) return process.env.CHROMIUM; const cache = join(homedir(), '.cache', 'ms-playwright'); const n = existsSync(cache) ? readdirSync(cache).map((d) => /^chromium-(\d+)$/.exec(d)).filter(Boolean).map((m) => +m![1]!).sort((a, b) => b - a) : []; for (const v of n) { const exe = join(cache, `chromium-${v}`, 'chrome-linux64', 'chrome'); if (existsSync(exe)) return exe; } return join(cache, 'chromium-introuvable', 'chrome'); }