From edac9166040dc09674072ce57af6a9c5ea958d85 Mon Sep 17 00:00:00 2001 From: David Sherret Date: Fri, 4 Oct 2024 08:52:00 +0100 Subject: fix(install): surface package.json dependency errors (#26023) --- cli/args/package_json.rs | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) (limited to 'cli/args/package_json.rs') diff --git a/cli/args/package_json.rs b/cli/args/package_json.rs index 2529e54fd..2ef39a30d 100644 --- a/cli/args/package_json.rs +++ b/cli/args/package_json.rs @@ -6,6 +6,7 @@ use std::sync::Arc; use deno_config::workspace::Workspace; use deno_core::serde_json; use deno_package_json::PackageJsonDepValue; +use deno_package_json::PackageJsonDepValueParseError; use deno_semver::npm::NpmPackageReqReference; use deno_semver::package::PackageReq; @@ -26,6 +27,7 @@ pub struct InstallNpmWorkspacePkg { pub struct NpmInstallDepsProvider { remote_pkgs: Vec, workspace_pkgs: Vec, + pkg_json_dep_errors: Vec, } impl NpmInstallDepsProvider { @@ -37,6 +39,7 @@ impl NpmInstallDepsProvider { // todo(dsherret): estimate capacity? let mut workspace_pkgs = Vec::new(); let mut remote_pkgs = Vec::new(); + let mut pkg_json_dep_errors = Vec::new(); let workspace_npm_pkgs = workspace.npm_packages(); for (_, folder) in workspace.config_folders() { @@ -83,8 +86,12 @@ impl NpmInstallDepsProvider { let deps = pkg_json.resolve_local_package_json_deps(); let mut pkg_pkgs = Vec::with_capacity(deps.len()); for (alias, dep) in deps { - let Ok(dep) = dep else { - continue; + let dep = match dep { + Ok(dep) => dep, + Err(err) => { + pkg_json_dep_errors.push(err); + continue; + } }; match dep { PackageJsonDepValue::Req(pkg_req) => { @@ -131,14 +138,19 @@ impl NpmInstallDepsProvider { Self { remote_pkgs, workspace_pkgs, + pkg_json_dep_errors, } } - pub fn remote_pkgs(&self) -> &Vec { + pub fn remote_pkgs(&self) -> &[InstallNpmRemotePkg] { &self.remote_pkgs } - pub fn workspace_pkgs(&self) -> &Vec { + pub fn workspace_pkgs(&self) -> &[InstallNpmWorkspacePkg] { &self.workspace_pkgs } + + pub fn pkg_json_dep_errors(&self) -> &[PackageJsonDepValueParseError] { + &self.pkg_json_dep_errors + } } -- cgit v1.2.3