From bb37dfb5b79c0e5ae18d34f01313cb1f39d7a2dd Mon Sep 17 00:00:00 2001 From: David Sherret Date: Mon, 22 May 2023 21:28:36 -0400 Subject: feat(lsp): support lockfile and node_modules directory (#19203) This adds support for the lockfile and node_modules directory to the lsp. In the case of the node_modules directory, it is only enabled when explicitly opted into via `"nodeModulesDir": true` in the configuration file. This is to reduce the language server automatically modifying the node_modules directory when the user doesn't want it to. Closes #16510 Closes #16373 --- cli/npm/resolvers/mod.rs | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'cli/npm/resolvers/mod.rs') diff --git a/cli/npm/resolvers/mod.rs b/cli/npm/resolvers/mod.rs index 168786407..26d954824 100644 --- a/cli/npm/resolvers/mod.rs +++ b/cli/npm/resolvers/mod.rs @@ -91,6 +91,16 @@ impl CliNpmResolver { self.fs_resolver.node_modules_path() } + /// Checks if the provided package req's folder is cached. + pub fn is_pkg_req_folder_cached(&self, req: &NpmPackageReq) -> bool { + self + .resolve_pkg_id_from_pkg_req(req) + .ok() + .and_then(|id| self.fs_resolver.package_folder(&id).ok()) + .map(|folder| folder.exists()) + .unwrap_or(false) + } + pub fn resolve_pkg_id_from_pkg_req( &self, req: &NpmPackageReq, -- cgit v1.2.3