Something went wrong. Try again.
fork of gpui
Something went wrong. Try again.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263use std::borrow::Cow;
use anyhow::{Result, bail};use async_trait::async_trait;use dap::{DapLocator, DebugRequest, adapters::DebugAdapterName};use gpui::{BackgroundExecutor, SharedString};
use task::{DebugScenario, SpawnInTerminal, TaskTemplate, VariableName};
pub(crate) struct NodeLocator;
const TYPESCRIPT_RUNNER_VARIABLE: VariableName = VariableName::Custom(Cow::Borrowed("TYPESCRIPT_RUNNER"));
#[async_trait]impl DapLocator for NodeLocator { fn name(&self) -> SharedString { SharedString::new_static("Node") }
/// Determines whether this locator can generate debug target for given task. async fn create_scenario( &self, build_config: &TaskTemplate, resolved_label: &str, adapter: &DebugAdapterName, ) -> Option<DebugScenario> { if adapter.0.as_ref() != "JavaScript" { return None; } if build_config.command != TYPESCRIPT_RUNNER_VARIABLE.template_value() && build_config.command != "npm" && build_config.command != "pnpm" && build_config.command != "yarn" { return None; }
let config = serde_json::json!({ "request": "launch", "type": "pwa-node", "args": build_config.args.clone(), "cwd": build_config.cwd.clone(), "runtimeExecutable": build_config.command.clone(), "env": build_config.env.clone(), "runtimeArgs": ["--inspect-brk"], "console": "integratedTerminal", });
Some(DebugScenario { adapter: adapter.0.clone(), label: resolved_label.to_string().into(), build: None, config, tcp_connection: None, }) }
async fn run(&self, _: SpawnInTerminal, _executor: BackgroundExecutor) -> Result<DebugRequest> { bail!("JavaScript locator should not require DapLocator::run to be ran"); }}