|
1 | 1 | #!/usr/bin/env node
|
2 |
| - |
3 |
| -import { env } from "@/env"; |
4 |
| -import { BrowserStackError } from "@/error"; |
5 |
| -import { ensureDirExists } from "@/fs-utils"; |
6 |
| -import { BrowserStack, LocalTestingBinaryOptions } from "@/index.node"; |
7 |
| -import { writeFileAtomic } from "@/write-file-atomic"; |
| 2 | +import { env } from "@/env.ts"; |
| 3 | +import { BrowserStackError } from "@/error.ts"; |
| 4 | +import { ensureDirExists } from "@/fs-utils.ts"; |
| 5 | +import { LocalTestingBinary, LocalTestingBinaryOptions } from "@/index.node.ts"; |
| 6 | +import { BufferEncoding, writeFileAtomic } from "@/write-file-atomic.ts"; |
8 | 7 | import cp from "node:child_process";
|
9 | 8 | import { readFile } from "node:fs/promises";
|
10 | 9 | import { createRequire } from "node:module";
|
11 | 10 | import { homedir, tmpdir } from "node:os";
|
12 | 11 | import { join } from "node:path";
|
| 12 | +import process from "node:process"; |
13 | 13 | import { onExit } from "signal-exit";
|
14 | 14 |
|
15 | 15 | const require = createRequire(import.meta.url);
|
@@ -44,10 +44,7 @@ async function start(
|
44 | 44 | statusPath
|
45 | 45 | );
|
46 | 46 |
|
47 |
| - const localTestingBinary = new BrowserStack.LocalTestingBinary({ |
48 |
| - ...options, |
49 |
| - }); |
50 |
| - |
| 47 | + const localTestingBinary = new LocalTestingBinary(options); |
51 | 48 | const localIdentifier = localTestingBinary.localIdentifier;
|
52 | 49 | let status: string | undefined;
|
53 | 50 |
|
@@ -79,7 +76,7 @@ async function stopInstance(
|
79 | 76 | options: Omit<LocalTestingBinaryOptions, "localIdentifier">,
|
80 | 77 | logger: Logger = globalThis.console
|
81 | 78 | ) {
|
82 |
| - const localTestingBinary = new BrowserStack.LocalTestingBinary({ |
| 79 | + const localTestingBinary = new LocalTestingBinary({ |
83 | 80 | ...options,
|
84 | 81 | localIdentifier,
|
85 | 82 | });
|
@@ -315,7 +312,7 @@ async function readOrCreateStatusFile(
|
315 | 312 | ): Promise<{ localIdentifiers: string[] } & Record<string, unknown>> {
|
316 | 313 | try {
|
317 | 314 | const contents = await readFile(statusPath, fileEncoding).then((data) =>
|
318 |
| - data.trim() |
| 315 | + data.toString().trim() |
319 | 316 | );
|
320 | 317 |
|
321 | 318 | if (contents.length) {
|
@@ -406,8 +403,9 @@ export async function main(
|
406 | 403 | const localIdentifier =
|
407 | 404 | resolveEnvLocalIdentifier() ??
|
408 | 405 | (args[1] === cmdSeparator ? undefined : args[1]);
|
409 |
| - |
410 |
| - const key = ensureKeyExists(args[2] === cmdSeparator ? undefined : args[2]); |
| 406 | + const key = ensureKeyExists( |
| 407 | + action === BrowserStackLocalAction.runWith ? undefined : args[2] |
| 408 | + ); |
411 | 409 | const binHome = await ensureBinHomeExists();
|
412 | 410 | const statusPath = join(binHome, "status.json");
|
413 | 411 |
|
|
0 commit comments