diff options
author | David Sherret <dsherret@users.noreply.github.com> | 2024-10-31 11:35:17 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-10-31 15:35:17 +0000 |
commit | 90edca21a26fd2decd0603fea37af10d1e11e454 (patch) | |
tree | 2b876c07709e1ad7f7343c96b2ebb2da7422458b /cli/npm | |
parent | 50ea707b58dff85b479905ebbeef866c95bc3cad (diff) |
fix: surface package.json location on dep parse failure (#26665)
Related: https://github.com/denoland/deno/issues/26653
Diffstat (limited to 'cli/npm')
-rw-r--r-- | cli/npm/managed/mod.rs | 20 |
1 files changed, 13 insertions, 7 deletions
diff --git a/cli/npm/managed/mod.rs b/cli/npm/managed/mod.rs index d0880557f..a0754812b 100644 --- a/cli/npm/managed/mod.rs +++ b/cli/npm/managed/mod.rs @@ -38,6 +38,7 @@ use crate::args::LifecycleScriptsConfig; use crate::args::NpmInstallDepsProvider; use crate::args::NpmProcessState; use crate::args::NpmProcessStateKind; +use crate::args::PackageJsonDepValueParseWithLocationError; use crate::cache::DenoCacheEnvFsAdapter; use crate::cache::FastInsecureHasher; use crate::http_util::HttpClientProvider; @@ -480,19 +481,24 @@ impl ManagedCliNpmResolver { self.resolution.resolve_pkg_id_from_pkg_req(req) } - pub fn ensure_no_pkg_json_dep_errors(&self) -> Result<(), AnyError> { + pub fn ensure_no_pkg_json_dep_errors( + &self, + ) -> Result<(), Box<PackageJsonDepValueParseWithLocationError>> { for err in self.npm_install_deps_provider.pkg_json_dep_errors() { - match err { + match &err.source { deno_package_json::PackageJsonDepValueParseError::VersionReq(_) => { - return Err( - AnyError::from(err.clone()) - .context("Failed to install from package.json"), - ); + return Err(Box::new(err.clone())); } deno_package_json::PackageJsonDepValueParseError::Unsupported { .. } => { - log::warn!("{} {} in package.json", colors::yellow("Warning"), err) + // only warn for this one + log::warn!( + "{} {}\n at {}", + colors::yellow("Warning"), + err.source, + err.location, + ) } } } |