diff options
author | Bartek IwaĆczuk <biwanczuk@gmail.com> | 2022-11-16 19:59:26 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-11-16 19:59:26 +0100 |
commit | bd159b8bad34acefbd6e222781f3d7c6319c9bef (patch) | |
tree | 98c23a6c23ff57174bfd663b733815c11a4f9f2e /cli/npm/resolvers/mod.rs | |
parent | 40a72f35550ad2fd995b1d176540cc4fa0858370 (diff) |
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
Diffstat (limited to 'cli/npm/resolvers/mod.rs')
-rw-r--r-- | cli/npm/resolvers/mod.rs | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/cli/npm/resolvers/mod.rs b/cli/npm/resolvers/mod.rs index f7c65c9e9..23cbde5d9 100644 --- a/cli/npm/resolvers/mod.rs +++ b/cli/npm/resolvers/mod.rs @@ -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(), |