From 1083c0ac53ff4679337e103eefa2d4787fb148f2 Mon Sep 17 00:00:00 2001 From: Cole Miller Date: Wed, 11 Jun 2025 19:28:45 -0400 Subject: [PATCH] debugger: Special-case `npm` et al. as `program` field for JS debug definitions (#32549) Send `runtimeExecutable` and `runtimeArgs` instead of `program` and `args` to avoid the DAP implicitly wrapping the command in `node`. This means that putting `pnpm vitest ` as the command in the launch modal will work, as will this in debug.json: ``` [ { "adapter": "JavaScript", "type": "pwa-node", "label": "Label", "request": "launch", "program": "pnpm", "args": ["vitest", ""], "cwd": "/Users/name/project" } ] ``` Release Notes: - Debugger Beta: made it possible to use commands like `pnpm ` in the launch modal and debug.json --- crates/dap_adapters/src/javascript.rs | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/crates/dap_adapters/src/javascript.rs b/crates/dap_adapters/src/javascript.rs index 67529f240a61d6abd841a43f494121ae5b44bf36..8981eade6158bb26dd6bdb52ea749bc5699abc57 100644 --- a/crates/dap_adapters/src/javascript.rs +++ b/crates/dap_adapters/src/javascript.rs @@ -71,6 +71,26 @@ impl JsDebugAdapter { let mut configuration = task_definition.config.clone(); if let Some(configuration) = configuration.as_object_mut() { + if let Some(program) = configuration + .get("program") + .cloned() + .and_then(|value| value.as_str().map(str::to_owned)) + { + match program.as_str() { + "npm" | "pnpm" | "yarn" | "bun" + if !configuration.contains_key("runtimeExecutable") + && !configuration.contains_key("runtimeArgs") => + { + configuration.remove("program"); + configuration.insert("runtimeExecutable".to_owned(), program.into()); + if let Some(args) = configuration.remove("args") { + configuration.insert("runtimeArgs".to_owned(), args); + } + } + _ => {} + } + } + configuration .entry("cwd") .or_insert(delegate.worktree_root_path().to_string_lossy().into());