Repository: denoland/deno
File: cli/args/mod.rs (Rust)

Code before:
    full_paths
  }

  pub fn lifecycle_scripts_config(&self) -> LifecycleScriptsConfig {
    LifecycleScriptsConfig {
      allowed: self.flags.allow_scripts.clone(),
      initial_cwd: self.initial_cwd.clone(),
      root_dir: self.workspace().root_dir_path(),
      explicit_install: matches!(
        self.sub_command(),
        DenoSubcommand::Install(_)
          | DenoSubcommand::Cache(_)
          | DenoSubcommand::Add(_)
      ),
    }
  }

  pub fn unstable_npm_lazy_caching(&self) -> bool {
    self.flags.unstable_config.npm_lazy_caching
      || self.workspace().has_unstable("npm-lazy-caching")
  }

  pub fn default_npm_caching_strategy(&self) -> NpmCachingStrategy {
    if self.flags.unstable_config.npm_lazy_caching {
      NpmCachingStrategy::Lazy
    } else if matches!(
      self.sub_command(),
      DenoSubcommand::Install(InstallFlags::Local(_))
        | DenoSubcommand::Add(_)
        | DenoSubcommand::Cache(_)
        | DenoSubcommand::Outdated(_)
    ) {
      NpmCachingStrategy::Manual
    } else {
      NpmCachingStrategy::Eager
    }
  }
}

pub(crate) fn unstable_lockfile_v5(
  flags: &Flags,
  workspace: &Workspace,
) -> bool {
  flags.unstable_config.lockfile_v5 || workspace.has_unstable("lockfile-v5")
}

fn try_resolve_node_binary_main_entrypoint(
  specifier: &str,
  initial_cwd: &Path,
) -> Result<Option<Url>, AnyError> {
  // node allows running files at paths without a `.js` extension

Review comment (suggestion):
drive by fix, it was using the eager caching strategy for these subcommands which causes `sync_resolution_with_fs` to run twice in some situations. Effectively we had regressed #25782 . This fixes it

Code after:
    full_paths
  }

  pub fn lifecycle_scripts_config(&self) -> LifecycleScriptsConfig {
    LifecycleScriptsConfig {
      allowed: self.flags.allow_scripts.clone(),
      initial_cwd: self.initial_cwd.clone(),
      root_dir: self.workspace().root_dir_path(),
      explicit_install: matches!(
        self.sub_command(),
        DenoSubcommand::Install(_)
          | DenoSubcommand::Cache(_)
          | DenoSubcommand::Add(_)
      ),
    }
  }

  pub fn unstable_npm_lazy_caching(&self) -> bool {
    self.flags.unstable_config.npm_lazy_caching
      || self.workspace().has_unstable("npm-lazy-caching")
  }

  pub fn default_npm_caching_strategy(&self) -> NpmCachingStrategy {
    if matches!(
      self.sub_command(),
      DenoSubcommand::Install(InstallFlags::Local(
        InstallFlagsLocal::TopLevel | InstallFlagsLocal::Add(_)
      )) | DenoSubcommand::Add(_)
        | DenoSubcommand::Outdated(_)
    ) {
      NpmCachingStrategy::Manual
    } else if self.flags.unstable_config.npm_lazy_caching {
      NpmCachingStrategy::Lazy
    } else {
      NpmCachingStrategy::Eager
    }
  }
}

pub(crate) fn unstable_lockfile_v5(
  flags: &Flags,
  workspace: &Workspace,
) -> bool {
  flags.unstable_config.lockfile_v5 || workspace.has_unstable("lockfile-v5")
}

fn try_resolve_node_binary_main_entrypoint(
  specifier: &str,
  initial_cwd: &Path,
) -> Result<Option<Url>, AnyError> {
  // node allows running files at paths without a `.js` extension