fix: don't print the same deprecation warning multiple times (#5149)

This commit is contained in:
Zoltan Kochan
2022-08-03 16:05:07 +03:00
committed by GitHub
parent 65c4260dee
commit 0321ca32a4
2 changed files with 11 additions and 3 deletions

View File

@@ -0,0 +1,6 @@
---
"@pnpm/resolve-dependencies": patch
"pnpm": patch
---
Don't print the same deprecation warning multiple times.

View File

@@ -925,7 +925,9 @@ async function resolveDependency (
status: 'resolved',
})
ctx.resolvedPackagesByDepPath[depPath] = await getResolvedPackage({
// WARN: It is very important to keep this sync
// Otherwise, deprecation messages for the same package might get written several times
ctx.resolvedPackagesByDepPath[depPath] = getResolvedPackage({
allowBuild: ctx.allowBuild,
dependencyLockfile: currentPkg.dependencyLockfile,
depPath,
@@ -1016,7 +1018,7 @@ function pkgIsLeaf (pkg: PackageManifest) {
isEmpty(pkg.peerDependencies ?? {})
}
async function getResolvedPackage (
function getResolvedPackage (
options: {
allowBuild?: (pkgName: string) => boolean
dependencyLockfile?: PackageSnapshot
@@ -1029,7 +1031,7 @@ async function getResolvedPackage (
prepare: boolean
wantedDependency: WantedDependency
}
): Promise<ResolvedPackage> {
): ResolvedPackage {
const peerDependencies = peerDependenciesWithoutOwn(options.pkg)
const requiresBuild = (options.allowBuild == null || options.allowBuild(options.pkg.name))