summaryrefslogtreecommitdiff
path: root/cli/lsp/config.rs
diff options
context:
space:
mode:
authorNayeem Rahman <nayeemrmn99@gmail.com>2024-07-08 22:31:27 +0100
committerGitHub <noreply@github.com>2024-07-08 22:31:27 +0100
commitd472c48b388992e2e0b059492dddf50400520809 (patch)
treef72848bb296ca81309f001fd63232c8473276dd6 /cli/lsp/config.rs
parentb338b541ac828113667fdd24c18db97d3e47c282 (diff)
fix(lsp): inherit workspace-root-only fields in members (#24440)
Diffstat (limited to 'cli/lsp/config.rs')
-rw-r--r--cli/lsp/config.rs63
1 files changed, 41 insertions, 22 deletions
diff --git a/cli/lsp/config.rs b/cli/lsp/config.rs
index 3fded336b..481273930 100644
--- a/cli/lsp/config.rs
+++ b/cli/lsp/config.rs
@@ -1299,16 +1299,27 @@ impl ConfigData {
}
};
- let vendor_dir = config_file.as_ref().and_then(|c| {
- if c.vendor() == Some(true) {
- Some(c.specifier.to_file_path().ok()?.parent()?.join("vendor"))
- } else {
- None
- }
- });
+ let vendor_dir = if let Some(workspace_root) = workspace_root {
+ workspace_root.vendor_dir.clone()
+ } else {
+ config_file.as_ref().and_then(|c| {
+ if c.vendor() == Some(true) {
+ Some(c.specifier.to_file_path().ok()?.parent()?.join("vendor"))
+ } else {
+ None
+ }
+ })
+ };
// Load lockfile
- let lockfile = config_file.as_ref().and_then(resolve_lockfile_from_config);
+ let lockfile = if let Some(workspace_root) = workspace_root {
+ workspace_root.lockfile.clone()
+ } else {
+ config_file
+ .as_ref()
+ .and_then(resolve_lockfile_from_config)
+ .map(Arc::new)
+ };
if let Some(lockfile) = &lockfile {
if let Ok(specifier) = ModuleSpecifier::from_file_path(&lockfile.filename)
{
@@ -1376,23 +1387,31 @@ impl ConfigData {
})
.map(|(r, _)| r)
.ok();
- let byonm = std::env::var("DENO_UNSTABLE_BYONM").is_ok()
- || config_file
- .as_ref()
- .map(|c| c.has_unstable("byonm"))
- .unwrap_or(false)
- || (*DENO_FUTURE
- && package_json.is_some()
- && config_file
+ let byonm = if let Some(workspace_root) = workspace_root {
+ workspace_root.byonm
+ } else {
+ std::env::var("DENO_UNSTABLE_BYONM").is_ok()
+ || config_file
.as_ref()
- .map(|c| c.json.node_modules_dir.is_none())
- .unwrap_or(true));
+ .map(|c| c.has_unstable("byonm"))
+ .unwrap_or(false)
+ || (*DENO_FUTURE
+ && package_json.is_some()
+ && config_file
+ .as_ref()
+ .map(|c| c.json.node_modules_dir.is_none())
+ .unwrap_or(true))
+ };
if byonm {
lsp_log!(" Enabled 'bring your own node_modules'.");
}
- let node_modules_dir = config_file
- .as_ref()
- .and_then(|c| resolve_node_modules_dir(c, byonm));
+ let node_modules_dir = if let Some(workspace_root) = workspace_root {
+ workspace_root.node_modules_dir.clone()
+ } else {
+ config_file
+ .as_ref()
+ .and_then(|c| resolve_node_modules_dir(c, byonm))
+ };
// Load import map
let mut import_map = None;
@@ -1547,7 +1566,7 @@ impl ConfigData {
byonm,
node_modules_dir,
vendor_dir,
- lockfile: lockfile.map(Arc::new),
+ lockfile,
package_json: package_json.map(Arc::new),
npmrc,
import_map,