Skip to content

Commit 8ab656c

Browse files
committed
fix: update path resolution in PuppeteerAdapter for better file handling
1 parent 6d35f32 commit 8ab656c

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/adapters/puppeteer.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,17 @@
11
import fs from "node:fs";
22
import libpath from "node:path";
3+
import path from "node:path";
4+
import { fileURLToPath } from "node:url";
35
import type { Page } from "puppeteer";
46
import {
57
DEFAULT_ACCEPTED_EVENT_NAMES,
68
DEFAULT_ACCEPTED_TAG_NAMES,
79
} from "../constants.js";
810
import type { Adapter, Device, TappableElement } from "../types.js";
911

12+
const __filename = fileURLToPath(import.meta.url);
13+
const __dirname = path.dirname(__filename);
14+
1015
export class PuppeteerAdapter implements Adapter {
1116
private page: Page;
1217

@@ -69,7 +74,7 @@ export class PuppeteerAdapter implements Adapter {
6974
);
7075

7176
const detector = fs
72-
.readFileSync(libpath.join(process.cwd(), "src/browser/detector.js"), {
77+
.readFileSync(libpath.join(__dirname, "../browser/detector.js"), {
7378
encoding: "utf-8",
7479
})
7580
.replace('"{{arg0}}"', JSON.stringify(DEFAULT_ACCEPTED_TAG_NAMES))

0 commit comments

Comments
 (0)