diff options
Diffstat (limited to 'cli/npm')
-rw-r--r-- | cli/npm/installer.rs | 6 | ||||
-rw-r--r-- | cli/npm/resolvers/mod.rs | 10 |
2 files changed, 16 insertions, 0 deletions
diff --git a/cli/npm/installer.rs b/cli/npm/installer.rs index 8590feb9c..adb4344ee 100644 --- a/cli/npm/installer.rs +++ b/cli/npm/installer.rs @@ -64,6 +64,12 @@ impl PackageJsonDepsInstaller { })) } + /// Creates an installer that never installs local packages during + /// resolution. A top level install will be a no-op. + pub fn no_op() -> Self { + Self(None) + } + /// Installs the top level dependencies in the package.json file /// without going through and resolving the descendant dependencies yet. pub async fn ensure_top_level_install(&self) -> Result<(), AnyError> { 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, |