diff options
author | David Sherret <dsherret@users.noreply.github.com> | 2024-07-18 18:16:35 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-07-18 18:16:35 -0400 |
commit | 3bda8eb4fe059fd79a522c9277a5a872f75dc270 (patch) | |
tree | 172d04d91223694c494b754d39c44ac5851575ac /cli/args/mod.rs | |
parent | 1722e0aebfd830b7cbc0824ace5de0517072d0dc (diff) |
fix(lsp): support npm workspaces and fix some resolution issues (#24627)
Makes the lsp use the same code as the rest of the cli.
Diffstat (limited to 'cli/args/mod.rs')
-rw-r--r-- | cli/args/mod.rs | 29 |
1 files changed, 18 insertions, 11 deletions
diff --git a/cli/args/mod.rs b/cli/args/mod.rs index 8b1b8e0c3..2c87be039 100644 --- a/cli/args/mod.rs +++ b/cli/args/mod.rs @@ -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)?; |