Skip to content

Commit e4cd5b4

Browse files
authored
Merge pull request #81 from ruturaj-browserstack/own_local_binary
feat: add USE_OWN_LOCAL_BINARY_PROCESS option to control local binary usage
2 parents b9c5ba5 + 241ac5f commit e4cd5b4

File tree

3 files changed

+30
-0
lines changed

3 files changed

+30
-0
lines changed

src/config.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,17 @@ for (const key of BROWSERSTACK_LOCAL_OPTION_KEYS) {
3030
}
3131
}
3232

33+
/**
34+
* USE_OWN_LOCAL_BINARY_PROCESS:
35+
* If true, the system will not start a new local binary process, but will use the user's own process.
36+
*/
3337
export class Config {
3438
constructor(
3539
public readonly browserstackUsername: string,
3640
public readonly browserstackAccessKey: string,
3741
public readonly DEV_MODE: boolean,
3842
public readonly browserstackLocalOptions: Record<string, any>,
43+
public readonly USE_OWN_LOCAL_BINARY_PROCESS: boolean,
3944
) {}
4045
}
4146

@@ -44,6 +49,7 @@ const config = new Config(
4449
process.env.BROWSERSTACK_ACCESS_KEY!,
4550
process.env.DEV_MODE === "true",
4651
browserstackLocalOptions,
52+
process.env.USE_OWN_LOCAL_BINARY_PROCESS === "true",
4753
);
4854

4955
export default config;

src/lib/local.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,24 @@ export async function ensureLocalBinarySetup(
8080
"Ensuring local binary setup as it is required for private URLs...",
8181
);
8282

83+
if (config.USE_OWN_LOCAL_BINARY_PROCESS) {
84+
logger.info(
85+
"Using user's own BrowserStack Local binary process, checking if it's running...",
86+
);
87+
88+
const isRunning = await isBrowserStackLocalRunning();
89+
if (!isRunning) {
90+
throw new Error(
91+
"USE_OWN_LOCAL_BINARY_PROCESS is enabled but BrowserStack Local process is not running. Please start your BrowserStack Local binary process first.",
92+
);
93+
}
94+
95+
logger.info(
96+
"BrowserStack Local process is running, proceeding with user's own process.",
97+
);
98+
return;
99+
}
100+
83101
const localBinary = new Local();
84102
await killExistingBrowserStackLocalProcesses();
85103

src/tools/accessiblity-utils/scanner.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,12 @@ export class AccessibilityScanner {
3535
const localHosts = new Set(["127.0.0.1", "localhost", "0.0.0.0"]);
3636
const BS_LOCAL_DOMAIN = "bs-local.com";
3737

38+
if (config.USE_OWN_LOCAL_BINARY_PROCESS && hasLocal) {
39+
throw new Error(
40+
"Cannot start scan with local URLs when using own BrowserStack Local binary process. Please set USE_OWN_LOCAL_BINARY_PROCESS to false.",
41+
);
42+
}
43+
3844
if (hasLocal) {
3945
await ensureLocalBinarySetup(localIdentifier);
4046
} else {

0 commit comments

Comments
 (0)