Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions src/chrome-launcher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,16 @@ const instances = new Set<Launcher>();

type JSONLike =|{[property: string]: JSONLike}|readonly JSONLike[]|string|number|boolean|null;

const windowsExePathRegex = /\.exe$/i;
const windowsMountPathRegex = /^\/mnt\/[a-z]\//i;

function isWindowsChromePath(chromePath: string | undefined) {
if (!chromePath) {
return false;
}
return windowsExePathRegex.test(chromePath) || windowsMountPathRegex.test(chromePath);
}

export interface Options {
startingUrl?: string;
chromeFlags?: Array<string>;
Expand Down Expand Up @@ -194,8 +204,8 @@ class Launcher {

if (!this.useDefaultProfile) {
// Place Chrome profile in a custom location we'll rm -rf later
// If in WSL, we need to use the Windows format
flags.push(`--user-data-dir=${isWsl ? toWin32Path(this.userDataDir) : this.userDataDir}`);
// If in WSL and using Windows Chrome binary, we need to use the Windows format
flags.push(`--user-data-dir=${isWsl && isWindowsChromePath(this.chromePath) ? toWin32Path(this.userDataDir) : this.userDataDir}`);
}

if (process.env.HEADLESS) flags.push('--headless');
Expand Down