From 5dea510b021d78a2c9b6aef9462ae6f4e0fd527a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bartek=20Iwa=C5=84czuk?= Date: Wed, 2 Nov 2022 16:32:30 +0100 Subject: fix(lock): autodiscovery of lockfile (#16498) This commit adds autodiscovery of lockfile. This only happens if Deno discovers the configuration file (either "deno.json" or "deno.jsonc"). In such case Deno tries to load "deno.lock" file that sits next to the configuration file, or creates one for user if the lockfile doesn't exist yet. As a consequence, "--lock" and "--lock-write" flags had been updated. "--lock" no longer requires a value, if one is not provided, it defaults to "./deno.lock" resolved from the current working directory. "--lock-write" description was updated to say that it forces to overwrite a lockfile. Autodiscovery is currently not handled by the LSP. --- cli/proc_state.rs | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'cli/proc_state.rs') diff --git a/cli/proc_state.rs b/cli/proc_state.rs index 3ea4214ab..148f44923 100644 --- a/cli/proc_state.rs +++ b/cli/proc_state.rs @@ -168,9 +168,7 @@ impl ProcState { Some(progress_bar.clone()), )?; - let lockfile = cli_options - .resolve_lock_file()? - .map(|f| Arc::new(Mutex::new(f))); + let lockfile = cli_options.maybe_lock_file(); let maybe_import_map_specifier = cli_options.resolve_import_map_specifier()?; @@ -296,7 +294,6 @@ impl ProcState { npm_package_reqs.push(package_ref.req); } } - let roots = roots .into_iter() .map(|s| (s, ModuleKind::Esm)) @@ -312,6 +309,13 @@ impl ProcState { self.options.type_check_mode() != TypeCheckMode::None, false, ) { + // TODO(bartlomieju): this is strange... ideally there should be only + // one codepath in `prepare_module_load` so we don't forget things + // like writing a lockfile. Figure a way to refactor this function. + if let Some(ref lockfile) = self.lockfile { + let g = lockfile.lock(); + g.write()?; + } return result; } } -- cgit v1.2.3