mirror of
https://github.com/denoland/deno.git
synced 2025-08-04 02:48:24 +00:00
fix(lock): ensure npm dependencies are written with --lock-write (#16668)
If "--lock-write" flag was present we never passed instance of the lockfile to the npm resolver, which made it skip adding discovered npm packages to the lockfile. This commit fixes that, by always passing lockfile to the npm resolver and only regenerating resolver snapshot is "--lock-write" is not present. Closes https://github.com/denoland/deno/issues/16666
This commit is contained in:
parent
40a72f3555
commit
bd159b8bad
3 changed files with 232 additions and 5 deletions
|
@ -104,10 +104,16 @@ impl NpmPackageResolver {
|
|||
|
||||
/// This function will replace current resolver with a new one built from a
|
||||
/// snapshot created out of the lockfile.
|
||||
pub async fn add_lockfile(
|
||||
pub async fn add_lockfile_and_maybe_regenerate_snapshot(
|
||||
&mut self,
|
||||
lockfile: Arc<Mutex<Lockfile>>,
|
||||
) -> Result<(), AnyError> {
|
||||
self.maybe_lockfile = Some(lockfile.clone());
|
||||
|
||||
if lockfile.lock().overwrite {
|
||||
return Ok(());
|
||||
}
|
||||
|
||||
let snapshot =
|
||||
NpmResolutionSnapshot::from_lockfile(lockfile.clone(), &self.api)
|
||||
.await
|
||||
|
@ -117,7 +123,6 @@ impl NpmPackageResolver {
|
|||
lockfile.lock().filename.display()
|
||||
)
|
||||
})?;
|
||||
self.maybe_lockfile = Some(lockfile);
|
||||
if let Some(node_modules_folder) = &self.local_node_modules_path {
|
||||
self.inner = Arc::new(LocalNpmPackageResolver::new(
|
||||
self.cache.clone(),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue