aboutsummaryrefslogtreecommitdiff
path: root/packages/bun-debug-adapter-protocol/src/debugger/adapter.ts
diff options
context:
space:
mode:
authorGravatar Ashcon Partovi <ashcon@partovi.net> 2023-08-25 22:20:22 -0700
committerGravatar Ashcon Partovi <ashcon@partovi.net> 2023-08-25 22:20:22 -0700
commitd0e2679fb5c37295e302f2113fcd0953638dc714 (patch)
treee76f62f69241f147ee12ea9ce0efbf2349fd8164 /packages/bun-debug-adapter-protocol/src/debugger/adapter.ts
parent764437eb6d451814bb65860645ad55cb38de74de (diff)
downloadbun-d0e2679fb5c37295e302f2113fcd0953638dc714.tar.gz
bun-d0e2679fb5c37295e302f2113fcd0953638dc714.tar.zst
bun-d0e2679fb5c37295e302f2113fcd0953638dc714.zip
More changes 2
Diffstat (limited to 'packages/bun-debug-adapter-protocol/src/debugger/adapter.ts')
-rw-r--r--packages/bun-debug-adapter-protocol/src/debugger/adapter.ts18
1 files changed, 13 insertions, 5 deletions
diff --git a/packages/bun-debug-adapter-protocol/src/debugger/adapter.ts b/packages/bun-debug-adapter-protocol/src/debugger/adapter.ts
index 288d56fb6..291645c34 100644
--- a/packages/bun-debug-adapter-protocol/src/debugger/adapter.ts
+++ b/packages/bun-debug-adapter-protocol/src/debugger/adapter.ts
@@ -256,6 +256,10 @@ export class DebugAdapter implements IDebugAdapter, InspectorListener {
}
const finalArgs = [...args];
+ if (isTestJavaScript(program)) {
+ finalArgs.unshift("test");
+ }
+
if (watch) {
finalArgs.push(watch === "hot" ? "--hot" : "--watch");
}
@@ -276,7 +280,7 @@ export class DebugAdapter implements IDebugAdapter, InspectorListener {
finalEnv["NO_COLOR"] = "1";
const subprocess = spawn(runtime, [...finalArgs, program], {
- stdio: ["ignore", "pipe", "pipe", "pipe"],
+ stdio: ["ignore", "pipe", "pipe"],
cwd,
env: finalEnv,
});
@@ -328,6 +332,10 @@ export class DebugAdapter implements IDebugAdapter, InspectorListener {
throw new Error(`Program exited with code ${reason} before the debugger could attached.`);
}
+ if (await this.#start()) {
+ return;
+ }
+
if (subprocess.exitCode === null && !subprocess.kill() && !subprocess.kill("SIGKILL")) {
this.#emit("output", {
category: "debug console",
@@ -335,10 +343,6 @@ export class DebugAdapter implements IDebugAdapter, InspectorListener {
});
}
- if (await this.#start()) {
- return;
- }
-
const { stdout: version } = spawnSync(runtime, ["--version"], { stdio: "pipe", encoding: "utf-8" });
const minVersion = "0.8.2";
@@ -1622,6 +1626,10 @@ function isJavaScript(path: string): boolean {
return /\.(c|m)?(j|t)sx?$/.test(path);
}
+function isTestJavaScript(path: string): boolean {
+ return /\.(test|spec)\.(c|m)?(j|t)sx?$/.test(path);
+}
+
function parseUrl(hostname?: string, port?: number): URL {
hostname ||= "localhost";
port ||= 6499;