Improve TypeScript task detection (#31711)
Parses project's package.json to better detect Jasmine, Jest, Vitest and Mocha and `test`, `build` scripts presence. Also tries to detect `pnpm` and `npx` as test runners, falls back to `npm`. https://github.com/user-attachments/assets/112d3d8b-8daa-4ba5-8cb5-2f483036bd98 Release Notes: - Improved TypeScript task detection
This commit is contained in:
parent
a23ee61a4b
commit
2abc5893c1
12 changed files with 469 additions and 43 deletions
|
@ -64,7 +64,7 @@ use std::{
|
|||
use std::{num::NonZeroU32, sync::OnceLock};
|
||||
use syntax_map::{QueryCursorHandle, SyntaxSnapshot};
|
||||
use task::RunnableTag;
|
||||
pub use task_context::{ContextProvider, RunnableRange};
|
||||
pub use task_context::{ContextLocation, ContextProvider, RunnableRange};
|
||||
pub use text_diff::{
|
||||
DiffOptions, apply_diff_patch, line_diff, text_diff, text_diff_with_options, unified_diff,
|
||||
};
|
||||
|
|
|
@ -1,9 +1,10 @@
|
|||
use std::{ops::Range, sync::Arc};
|
||||
use std::{ops::Range, path::PathBuf, sync::Arc};
|
||||
|
||||
use crate::{LanguageToolchainStore, Location, Runnable};
|
||||
|
||||
use anyhow::Result;
|
||||
use collections::HashMap;
|
||||
use fs::Fs;
|
||||
use gpui::{App, Task};
|
||||
use lsp::LanguageServerName;
|
||||
use task::{TaskTemplates, TaskVariables};
|
||||
|
@ -26,11 +27,12 @@ pub trait ContextProvider: Send + Sync {
|
|||
fn build_context(
|
||||
&self,
|
||||
_variables: &TaskVariables,
|
||||
_location: &Location,
|
||||
_location: ContextLocation<'_>,
|
||||
_project_env: Option<HashMap<String, String>>,
|
||||
_toolchains: Arc<dyn LanguageToolchainStore>,
|
||||
_cx: &mut App,
|
||||
) -> Task<Result<TaskVariables>> {
|
||||
let _ = _location;
|
||||
Task::ready(Ok(TaskVariables::default()))
|
||||
}
|
||||
|
||||
|
@ -48,3 +50,10 @@ pub trait ContextProvider: Send + Sync {
|
|||
None
|
||||
}
|
||||
}
|
||||
|
||||
/// Metadata about the place in the project we gather the context for.
|
||||
pub struct ContextLocation<'a> {
|
||||
pub fs: Option<Arc<dyn Fs>>,
|
||||
pub worktree_root: Option<PathBuf>,
|
||||
pub file_location: &'a Location,
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue