Skip to content

Commit

Permalink
Added custom browserContext for each session (#111)
Browse files Browse the repository at this point in the history
* Added custom browserContext for each session

* Fixed the order of operation when handling --user-data-dir parameter
  • Loading branch information
tpkowastaken authored Nov 13, 2024
1 parent 7ce5b21 commit b9506c0
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/browser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,11 @@ export async function launch(opts?: LaunchOptions): Promise<Browser> {
path = await getBinary(product, { cache });
}

if (!args.find((arg) => arg.startsWith("--user-data-dir="))) {
const tempDir = Deno.makeTempDirSync();
args.push(`--user-data-dir=${tempDir}`);
}

// Launch child process
const binArgs = [
"--remote-debugging-port=0",
Expand All @@ -275,11 +280,6 @@ export async function launch(opts?: LaunchOptions): Promise<Browser> {
...args,
];

if (!args.find((arg) => arg.startsWith("--user-data-dir="))) {
const tempDir = Deno.makeTempDirSync();
args.push(`--user-data-dir=${tempDir}`);
}

if (DEBUG) {
console.log(`Launching: ${path} ${binArgs.join(" ")}`);
}
Expand Down

0 comments on commit b9506c0

Please sign in to comment.