From bc8a0e6e68547cf07a246b8b6c886de155dc8282 Mon Sep 17 00:00:00 2001 From: Nathan Whitaker <17734409+nathanwhit@users.noreply.github.com> Date: Fri, 28 Jun 2024 17:18:21 -0700 Subject: refactor(cli): Create wrapper around `deno_lockfile::Lockfile` (#24366) As suggested in https://github.com/denoland/deno/pull/24355#discussion_r1657875422. I wasn't able to hide the mutex stuff as much as I'd like (ended up just adding an escape hatch `inner()` method that locks the inner mutex), because you can't return references to the inner fields through a mutex. This is mostly motivated by the frozen lockfile changes --- cli/tools/info.rs | 3 +-- cli/tools/installer.rs | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-) (limited to 'cli/tools') diff --git a/cli/tools/info.rs b/cli/tools/info.rs index 17e854519..76951b13d 100644 --- a/cli/tools/info.rs +++ b/cli/tools/info.rs @@ -25,7 +25,6 @@ use deno_semver::npm::NpmPackageReqReference; use deno_semver::package::PackageNv; use deno_terminal::colors; -use crate::args::write_lockfile_if_has_changes; use crate::args::Flags; use crate::args::InfoFlags; use crate::display; @@ -71,7 +70,7 @@ pub async fn info(flags: Flags, info_flags: InfoFlags) -> Result<(), AnyError> { // write out the lockfile if there is one if let Some(lockfile) = &maybe_lockfile { graph_exit_lock_errors(&graph); - write_lockfile_if_has_changes(&mut lockfile.lock())?; + lockfile.write_if_changed()?; } if info_flags.json { diff --git a/cli/tools/installer.rs b/cli/tools/installer.rs index c920489f2..9704e5966 100644 --- a/cli/tools/installer.rs +++ b/cli/tools/installer.rs @@ -1,7 +1,6 @@ // Copyright 2018-2024 the Deno authors. All rights reserved. MIT license. use crate::args::resolve_no_prompt; -use crate::args::write_lockfile_if_has_changes; use crate::args::AddFlags; use crate::args::CaData; use crate::args::Flags; @@ -273,7 +272,7 @@ async fn install_local( crate::module_loader::load_top_level_deps(&factory).await?; if let Some(lockfile) = factory.cli_options().maybe_lockfile() { - write_lockfile_if_has_changes(&mut lockfile.lock())?; + lockfile.write_if_changed()?; } Ok(()) -- cgit v1.2.3