summaryrefslogtreecommitdiff
path: root/cli/args
diff options
context:
space:
mode:
authorDavid Sherret <dsherret@users.noreply.github.com>2024-10-04 08:52:00 +0100
committerGitHub <noreply@github.com>2024-10-04 07:52:00 +0000
commitedac9166040dc09674072ce57af6a9c5ea958d85 (patch)
tree0a54e2946b8d6146e3620b4859c6d609d1c657ee /cli/args
parentb8a9a4a862e4d61630c5bc8089261c7a177ec97a (diff)
fix(install): surface package.json dependency errors (#26023)
Diffstat (limited to 'cli/args')
-rw-r--r--cli/args/flags.rs2
-rw-r--r--cli/args/package_json.rs20
2 files changed, 18 insertions, 4 deletions
diff --git a/cli/args/flags.rs b/cli/args/flags.rs
index 06ce50783..258712ca9 100644
--- a/cli/args/flags.rs
+++ b/cli/args/flags.rs
@@ -2910,6 +2910,7 @@ List all available tasks:
.help("Specify the directory to run the task in")
.value_hint(ValueHint::DirPath),
)
+ .arg(node_modules_dir_arg())
})
}
@@ -4974,6 +4975,7 @@ fn task_parse(flags: &mut Flags, matches: &mut ArgMatches) {
.unwrap_or(ConfigFlag::Discover);
unstable_args_parse(flags, matches, UnstableArgsConfig::ResolutionAndRuntime);
+ node_modules_arg_parse(flags, matches);
let mut task_flags = TaskFlags {
cwd: matches.remove_one::<String>("cwd"),
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<InstallNpmRemotePkg>,
workspace_pkgs: Vec<InstallNpmWorkspacePkg>,
+ pkg_json_dep_errors: Vec<PackageJsonDepValueParseError>,
}
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<InstallNpmRemotePkg> {
+ pub fn remote_pkgs(&self) -> &[InstallNpmRemotePkg] {
&self.remote_pkgs
}
- pub fn workspace_pkgs(&self) -> &Vec<InstallNpmWorkspacePkg> {
+ pub fn workspace_pkgs(&self) -> &[InstallNpmWorkspacePkg] {
&self.workspace_pkgs
}
+
+ pub fn pkg_json_dep_errors(&self) -> &[PackageJsonDepValueParseError] {
+ &self.pkg_json_dep_errors
+ }
}