diff options
| author | Bartek IwaĆczuk <biwanczuk@gmail.com> | 2022-11-02 16:32:30 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-11-02 16:32:30 +0100 |
| commit | 5dea510b021d78a2c9b6aef9462ae6f4e0fd527a (patch) | |
| tree | 728b3663f2852fae25df72ab2599c3cbebfc8ac9 /cli/proc_state.rs | |
| parent | 630abb58b08827e63e56f519bf59a84c3283ab23 (diff) | |
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.
Diffstat (limited to 'cli/proc_state.rs')
| -rw-r--r-- | cli/proc_state.rs | 12 |
1 files changed, 8 insertions, 4 deletions
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; } } |
