shots / console: resolve playwright only from an installed node_modules copy; in a project without playwright Bun auto-installed the newest one into its global cache, whose browsers were never downloaded (capture-web on Linux CI: 'headless shell: not installed'; macOS hid it with Google Chrome)
This commit is contained in:
parent
56591f4118
commit
b9579e2a2e
2 changed files with 26 additions and 1 deletions
|
|
@ -29,6 +29,10 @@ async function chromium(root: string): Promise<any> {
|
|||
for (const base of [root, join(import.meta.dir, '../..')]) {
|
||||
try {
|
||||
const p = Bun.resolveSync('playwright', base);
|
||||
// only an installed copy (node_modules): outside a project Bun auto-installs the newest playwright into its global
|
||||
// cache (~/.bun/install/cache), whose browser build was never downloaded ("headless shell: not installed" on
|
||||
// Linux CI, where no Google Chrome hides it); storebound's own copy is next
|
||||
if (!isInstalledPackage(p)) continue;
|
||||
return (await import(p)).chromium;
|
||||
} catch { /* next */ }
|
||||
}
|
||||
|
|
@ -37,6 +41,9 @@ async function chromium(root: string): Promise<any> {
|
|||
throw new Error('playwright not found: in your project run `bun add -d playwright` (and `bunx playwright install chromium` if Google Chrome is not installed)');
|
||||
}
|
||||
|
||||
/** A resolved module path inside a node_modules folder (not one of Bun's auto-installs from its global cache). */
|
||||
export const isInstalledPackage = (resolved: string): boolean => /[\\/]node_modules[\\/]/.test(resolved);
|
||||
|
||||
/** Playwright's chromium (same resolution as `launch`), for connectOverCDP. */
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
export const chromiumFor = (root: string): Promise<any> => chromium(root);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue