diff options
author | 2023-08-19 23:20:29 -0700 | |
---|---|---|
committer | 2023-08-24 20:11:20 -0700 | |
commit | e1c00ebaaf4185099aaa461ce17220baa115ab94 (patch) | |
tree | 7d8e60625297c4a2c040a7246734af2322b0ef96 /packages/bun-debug-adapter-protocol/debugger/adapter.ts | |
parent | 6313655c8e0d5bb0378029199fa329f3750f6ca6 (diff) | |
download | bun-e1c00ebaaf4185099aaa461ce17220baa115ab94.tar.gz bun-e1c00ebaaf4185099aaa461ce17220baa115ab94.tar.zst bun-e1c00ebaaf4185099aaa461ce17220baa115ab94.zip |
Check bun version if it fails
Diffstat (limited to 'packages/bun-debug-adapter-protocol/debugger/adapter.ts')
-rw-r--r-- | packages/bun-debug-adapter-protocol/debugger/adapter.ts | 23 |
1 files changed, 16 insertions, 7 deletions
diff --git a/packages/bun-debug-adapter-protocol/debugger/adapter.ts b/packages/bun-debug-adapter-protocol/debugger/adapter.ts index c86fb2d85..1dfdcf7bb 100644 --- a/packages/bun-debug-adapter-protocol/debugger/adapter.ts +++ b/packages/bun-debug-adapter-protocol/debugger/adapter.ts @@ -5,6 +5,7 @@ import type { ChildProcess } from "node:child_process"; import { spawn, spawnSync } from "node:child_process"; import capabilities from "./capabilities"; import { SourceMap } from "./sourcemap"; +import { compare, parse } from "semver"; type LaunchRequest = DAP.LaunchRequest & { runtime?: string; @@ -337,6 +338,21 @@ export class DebugAdapter implements IDebugAdapter, InspectorListener { return; } + if (subprocess.exitCode === null && !subprocess.kill() && !subprocess.kill("SIGKILL")) { + this.#emit("output", { + category: "debug console", + output: `Failed to kill process ${subprocess.pid}\n`, + }); + } + + const { stdout: version } = spawnSync(runtime, ["--version"], { stdio: "pipe", encoding: "utf-8" }); + + if (parse(version, true) && compare("0.8.0", version, true)) { + throw new Error( + `Bun v${version.trim()} does not have debugger support. Please upgrade to v0.8 or later by running: \`bun upgrade\``, + ); + } + for (const message of stderr) { this.#emit("output", { category: "stderr", @@ -357,13 +373,6 @@ export class DebugAdapter implements IDebugAdapter, InspectorListener { }); } - if (subprocess.exitCode === null && !subprocess.kill() && !subprocess.kill("SIGKILL")) { - this.#emit("output", { - category: "debug console", - output: `Failed to kill process ${subprocess.pid}\n`, - }); - } - throw new Error("Program started, but the debugger could not be attached."); } |