mirror of
https://github.com/denoland/deno.git
synced 2025-08-04 02:48:24 +00:00
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
This commit is contained in:
parent
2ddae872f9
commit
bc8a0e6e68
12 changed files with 181 additions and 141 deletions
|
@ -2,7 +2,7 @@
|
|||
|
||||
use super::logging::lsp_log;
|
||||
use crate::args::discover_npmrc;
|
||||
use crate::args::read_lockfile_at_path;
|
||||
use crate::args::CliLockfile;
|
||||
use crate::args::ConfigFile;
|
||||
use crate::args::FmtOptions;
|
||||
use crate::args::LintOptions;
|
||||
|
@ -18,7 +18,6 @@ use deno_config::FmtOptionsConfig;
|
|||
use deno_config::TsConfig;
|
||||
use deno_core::anyhow::anyhow;
|
||||
use deno_core::normalize_path;
|
||||
use deno_core::parking_lot::Mutex;
|
||||
use deno_core::serde::de::DeserializeOwned;
|
||||
use deno_core::serde::Deserialize;
|
||||
use deno_core::serde::Serialize;
|
||||
|
@ -27,7 +26,6 @@ use deno_core::serde_json::json;
|
|||
use deno_core::serde_json::Value;
|
||||
use deno_core::ModuleSpecifier;
|
||||
use deno_lint::linter::LintConfig;
|
||||
use deno_lockfile::Lockfile;
|
||||
use deno_npm::npm_rc::ResolvedNpmRc;
|
||||
use deno_runtime::deno_node::PackageJson;
|
||||
use deno_runtime::deno_permissions::PermissionsContainer;
|
||||
|
@ -1111,7 +1109,7 @@ pub struct ConfigData {
|
|||
pub byonm: bool,
|
||||
pub node_modules_dir: Option<PathBuf>,
|
||||
pub vendor_dir: Option<PathBuf>,
|
||||
pub lockfile: Option<Arc<Mutex<Lockfile>>>,
|
||||
pub lockfile: Option<Arc<CliLockfile>>,
|
||||
pub package_json: Option<Arc<PackageJson>>,
|
||||
pub npmrc: Option<Arc<ResolvedNpmRc>>,
|
||||
pub import_map: Option<Arc<ImportMap>>,
|
||||
|
@ -1553,7 +1551,7 @@ impl ConfigData {
|
|||
byonm,
|
||||
node_modules_dir,
|
||||
vendor_dir,
|
||||
lockfile: lockfile.map(Mutex::new).map(Arc::new),
|
||||
lockfile: lockfile.map(Arc::new),
|
||||
package_json: package_json.map(Arc::new),
|
||||
npmrc,
|
||||
import_map,
|
||||
|
@ -1786,7 +1784,9 @@ impl ConfigTree {
|
|||
}
|
||||
}
|
||||
|
||||
fn resolve_lockfile_from_config(config_file: &ConfigFile) -> Option<Lockfile> {
|
||||
fn resolve_lockfile_from_config(
|
||||
config_file: &ConfigFile,
|
||||
) -> Option<CliLockfile> {
|
||||
let lockfile_path = match config_file.resolve_lockfile_path() {
|
||||
Ok(Some(value)) => value,
|
||||
Ok(None) => return None,
|
||||
|
@ -1824,8 +1824,8 @@ fn resolve_node_modules_dir(
|
|||
canonicalize_path_maybe_not_exists(&node_modules_dir).ok()
|
||||
}
|
||||
|
||||
fn resolve_lockfile_from_path(lockfile_path: PathBuf) -> Option<Lockfile> {
|
||||
match read_lockfile_at_path(lockfile_path) {
|
||||
fn resolve_lockfile_from_path(lockfile_path: PathBuf) -> Option<CliLockfile> {
|
||||
match CliLockfile::read_from_path(lockfile_path) {
|
||||
Ok(value) => {
|
||||
if value.filename.exists() {
|
||||
if let Ok(specifier) = ModuleSpecifier::from_file_path(&value.filename)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue