diff options
author | David Sherret <dsherret@users.noreply.github.com> | 2024-04-05 10:34:51 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-04-05 10:34:51 -0400 |
commit | 049e703331409db8c4b4e2cc7d969f471c229df3 (patch) | |
tree | a31458a651e931d2047c348bdcbe0379470bf925 /cli | |
parent | ee4bfe16009c3a04c9015bf9fca0c9b0f9a3a601 (diff) |
FUTURE: override byonm with nodeModulesDir setting (#23222)
Makes the `"nodeModulesDir"` setting take precedence over byonm when
using `DENO_FUTURE`.
Diffstat (limited to 'cli')
-rw-r--r-- | cli/args/mod.rs | 20 | ||||
-rw-r--r-- | cli/factory.rs | 8 | ||||
-rw-r--r-- | cli/standalone/binary.rs | 2 | ||||
-rw-r--r-- | cli/tools/vendor/mod.rs | 15 |
4 files changed, 23 insertions, 22 deletions
diff --git a/cli/args/mod.rs b/cli/args/mod.rs index e138e9d0b..8a65514bf 100644 --- a/cli/args/mod.rs +++ b/cli/args/mod.rs @@ -1102,15 +1102,11 @@ impl CliOptions { } pub fn has_node_modules_dir(&self) -> bool { - if self.enable_future_features() { - self.maybe_node_modules_folder.is_some() - } else { - self.maybe_node_modules_folder.is_some() || self.unstable_byonm() - } + self.maybe_node_modules_folder.is_some() } - pub fn node_modules_dir_path(&self) -> Option<PathBuf> { - self.maybe_node_modules_folder.clone() + pub fn node_modules_dir_path(&self) -> Option<&PathBuf> { + self.maybe_node_modules_folder.as_ref() } pub fn with_node_modules_dir_path(&self, path: PathBuf) -> Self { @@ -1595,10 +1591,14 @@ impl CliOptions { } pub fn use_byonm(&self) -> bool { - self.enable_future_features() - } + if self.enable_future_features() + && self.node_modules_dir_enablement().is_none() + && self.maybe_package_json.is_some() + { + return true; + } - pub fn unstable_byonm(&self) -> bool { + // check if enabled via unstable self.flags.unstable_config.byonm || NPM_PROCESS_STATE .as_ref() diff --git a/cli/factory.rs b/cli/factory.rs index bd8fa7ef6..18f6b6b2a 100644 --- a/cli/factory.rs +++ b/cli/factory.rs @@ -402,11 +402,11 @@ impl CliFactory { .npm_resolver .get_or_try_init_async(async { let fs = self.fs(); - create_cli_npm_resolver(if self.options.use_byonm() || self.options.unstable_byonm() { + create_cli_npm_resolver(if self.options.use_byonm() { CliNpmResolverCreateOptions::Byonm(CliNpmResolverByonmCreateOptions { fs: fs.clone(), - root_node_modules_dir: match self.options.node_modules_dir_path().clone() { - Some(node_modules_path) => node_modules_path, + root_node_modules_dir: match self.options.node_modules_dir_path() { + Some(node_modules_path) => node_modules_path.to_path_buf(), // path needs to be canonicalized for node resolution // (node_modules_dir_path above is already canonicalized) None => canonicalize_path_maybe_not_exists(self.options.initial_cwd())? @@ -434,7 +434,7 @@ impl CliFactory { npm_global_cache_dir: self.deno_dir()?.npm_folder_path(), cache_setting: self.options.cache_setting(), text_only_progress_bar: self.text_only_progress_bar().clone(), - maybe_node_modules_path: self.options.node_modules_dir_path(), + maybe_node_modules_path: self.options.node_modules_dir_path().cloned(), package_json_installer: CliNpmResolverManagedPackageJsonInstallerOption::ConditionalInstall( self.package_json_deps_provider().clone(), diff --git a/cli/standalone/binary.rs b/cli/standalone/binary.rs index bd0735dd1..c96d83854 100644 --- a/cli/standalone/binary.rs +++ b/cli/standalone/binary.rs @@ -635,7 +635,7 @@ impl<'a> DenoCompileBinaryWriter<'a> { unstable_config: UnstableConfig { legacy_flag_enabled: cli_options.legacy_unstable_flag(), bare_node_builtins: cli_options.unstable_bare_node_builtins(), - byonm: cli_options.use_byonm() || cli_options.unstable_byonm(), + byonm: cli_options.use_byonm(), sloppy_imports: cli_options.unstable_sloppy_imports(), features: cli_options.unstable_features(), }, diff --git a/cli/tools/vendor/mod.rs b/cli/tools/vendor/mod.rs index 2e01d1963..5a76365ee 100644 --- a/cli/tools/vendor/mod.rs +++ b/cli/tools/vendor/mod.rs @@ -99,13 +99,14 @@ pub async fn vendor( // cache the node_modules folder when it's been added to the config file if modified_result.added_node_modules_dir { - let node_modules_path = cli_options.node_modules_dir_path().or_else(|| { - cli_options - .maybe_config_file_specifier() - .filter(|c| c.scheme() == "file") - .and_then(|c| c.to_file_path().ok()) - .map(|config_path| config_path.parent().unwrap().join("node_modules")) - }); + let node_modules_path = + cli_options.node_modules_dir_path().cloned().or_else(|| { + cli_options + .maybe_config_file_specifier() + .filter(|c| c.scheme() == "file") + .and_then(|c| c.to_file_path().ok()) + .map(|config_path| config_path.parent().unwrap().join("node_modules")) + }); if let Some(node_modules_path) = node_modules_path { let cli_options = cli_options.with_node_modules_dir_path(node_modules_path); |