mirror of
https://github.com/denoland/deno.git
synced 2025-08-03 18:38:33 +00:00
fix(lsp): support npm workspaces and fix some resolution issues (#24627)
Makes the lsp use the same code as the rest of the cli.
This commit is contained in:
parent
1722e0aebf
commit
3bda8eb4fe
11 changed files with 1053 additions and 800 deletions
|
@ -500,6 +500,22 @@ fn resolve_lint_rules_options(
|
|||
}
|
||||
}
|
||||
|
||||
pub fn discover_npmrc_from_workspace(
|
||||
workspace: &Workspace,
|
||||
) -> Result<(Arc<ResolvedNpmRc>, Option<PathBuf>), AnyError> {
|
||||
let root_folder = workspace.root_folder().1;
|
||||
discover_npmrc(
|
||||
root_folder.pkg_json.as_ref().map(|p| p.path.clone()),
|
||||
root_folder.deno_json.as_ref().and_then(|cf| {
|
||||
if cf.specifier.scheme() == "file" {
|
||||
Some(cf.specifier.to_file_path().unwrap())
|
||||
} else {
|
||||
None
|
||||
}
|
||||
}),
|
||||
)
|
||||
}
|
||||
|
||||
/// Discover `.npmrc` file - currently we only support it next to `package.json`
|
||||
/// or next to `deno.json`.
|
||||
///
|
||||
|
@ -846,6 +862,7 @@ impl CliOptions {
|
|||
}
|
||||
WorkspaceDiscoverOptions {
|
||||
fs: &config_fs_adapter,
|
||||
deno_json_cache: None,
|
||||
pkg_json_cache: Some(
|
||||
&deno_runtime::deno_node::PackageJsonThreadLocalCache,
|
||||
),
|
||||
|
@ -890,17 +907,7 @@ impl CliOptions {
|
|||
log::warn!("{} {}", colors::yellow("Warning"), diagnostic);
|
||||
}
|
||||
|
||||
let root_folder = workspace.root_folder().1;
|
||||
let (npmrc, _) = discover_npmrc(
|
||||
root_folder.pkg_json.as_ref().map(|p| p.path.clone()),
|
||||
root_folder.deno_json.as_ref().and_then(|cf| {
|
||||
if cf.specifier.scheme() == "file" {
|
||||
Some(cf.specifier.to_file_path().unwrap())
|
||||
} else {
|
||||
None
|
||||
}
|
||||
}),
|
||||
)?;
|
||||
let (npmrc, _) = discover_npmrc_from_workspace(&workspace)?;
|
||||
|
||||
let maybe_lock_file = CliLockfile::discover(&flags, &workspace)?;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue