diff options
Diffstat (limited to 'cli/lsp')
-rw-r--r-- | cli/lsp/config.rs | 5 | ||||
-rw-r--r-- | cli/lsp/language_server.rs | 4 | ||||
-rw-r--r-- | cli/lsp/resolver.rs | 6 |
3 files changed, 14 insertions, 1 deletions
diff --git a/cli/lsp/config.rs b/cli/lsp/config.rs index 597f45688..89ecb84d8 100644 --- a/cli/lsp/config.rs +++ b/cli/lsp/config.rs @@ -24,6 +24,7 @@ use deno_core::serde_json::json; use deno_core::serde_json::Value; use deno_core::ModuleSpecifier; use deno_lockfile::Lockfile; +use deno_npm::npm_rc::ResolvedNpmRc; use deno_runtime::deno_node::PackageJson; use deno_runtime::fs_util::specifier_to_file_path; use deno_runtime::permissions::PermissionsContainer; @@ -1090,6 +1091,7 @@ pub struct ConfigData { pub vendor_dir: Option<PathBuf>, pub lockfile: Option<Arc<Mutex<Lockfile>>>, pub package_json: Option<Arc<PackageJson>>, + pub npmrc: Option<Arc<ResolvedNpmRc>>, pub import_map: Option<Arc<ImportMap>>, pub import_map_from_settings: bool, watched_files: HashMap<ModuleSpecifier, ConfigWatchedFileType>, @@ -1274,6 +1276,8 @@ impl ConfigData { // Load package.json let mut package_json = None; + // TODO(bartlomieju): support discovering .npmrc + let npmrc = None; if let Ok(path) = specifier_to_file_path(scope) { let path = path.join("package.json"); if let Ok(specifier) = ModuleSpecifier::from_file_path(&path) { @@ -1429,6 +1433,7 @@ impl ConfigData { vendor_dir, lockfile: lockfile.map(Mutex::new).map(Arc::new), package_json: package_json.map(Arc::new), + npmrc: npmrc.map(Arc::new), import_map: import_map.map(Arc::new), import_map_from_settings, watched_files, diff --git a/cli/lsp/language_server.rs b/cli/lsp/language_server.rs index 17ed02cd6..8f37d8b9c 100644 --- a/cli/lsp/language_server.rs +++ b/cli/lsp/language_server.rs @@ -83,6 +83,7 @@ use super::tsc::ChangeKind; use super::tsc::GetCompletionDetailsArgs; use super::tsc::TsServer; use super::urls; +use crate::args::create_default_npmrc; use crate::args::get_root_cert_store; use crate::args::CaData; use crate::args::CacheSetting; @@ -3318,6 +3319,9 @@ impl Inner { config_data.and_then(|d| d.config_file.as_deref().cloned()), config_data.and_then(|d| d.lockfile.clone()), config_data.and_then(|d| d.package_json.as_deref().cloned()), + config_data + .and_then(|d| d.npmrc.clone()) + .unwrap_or_else(create_default_npmrc), force_global_cache, )?; diff --git a/cli/lsp/resolver.rs b/cli/lsp/resolver.rs index c4d97177f..0567bba86 100644 --- a/cli/lsp/resolver.rs +++ b/cli/lsp/resolver.rs @@ -1,5 +1,6 @@ // Copyright 2018-2024 the Deno authors. All rights reserved. MIT license. +use crate::args::create_default_npmrc; use crate::args::package_json; use crate::args::CacheSetting; use crate::cache::FastInsecureHasher; @@ -363,7 +364,10 @@ async fn create_npm_resolver( // do not install while resolving in the lsp—leave that to the cache command package_json_installer: CliNpmResolverManagedPackageJsonInstallerOption::NoInstall, - npm_registry_url: crate::args::npm_registry_url().to_owned(), + npmrc: config_data + .npmrc + .clone() + .unwrap_or_else(create_default_npmrc), npm_system_info: NpmSystemInfo::default(), }) }; |