fix: install exiting with 1 exit code and no error message (#9567)

close #9559
This commit is contained in:
Zoltan Kochan
2025-05-22 15:26:51 +02:00
parent 55424eb581
commit 32dadefb53
4 changed files with 46 additions and 2 deletions

View File

@@ -0,0 +1,6 @@
---
"@pnpm/core": patch
"pnpm": patch
---
Installation should not exit with an error if `strictPeerDependencies` is `true` but all issues are ignored by `peerDependencyRules` [#9505](https://github.com/pnpm/pnpm/pull/9505).

View File

@@ -444,7 +444,12 @@ function reportPeerDependencyIssuesError (
strictPeerDependencies: false
`)
const rendered = renderPeerIssues(msg.issuesByProjects)
if (!rendered) return null
if (!rendered) {
// This should never happen.
return {
title: err.message,
}
}
return {
title: err.message,
body: `${rendered}

View File

@@ -45,7 +45,7 @@ export function filterPeerDependencyIssues (
newPeerDependencyIssuesByProjects[projectId] = { bad: {}, missing: {}, conflicts, intersections }
for (const [peerName, issues] of Object.entries(missing)) {
if (
ignoreMissingMatcher(peerName)
ignoreMissingMatcher(peerName) || issues.every(({ optional }) => optional)
) {
continue
}

View File

@@ -207,3 +207,36 @@ test('filterPeerDependencyIssues() allowed versions', () => {
},
})
})
test('filterPeerDependencyIssues() ignores missing optional dependency issues', () => {
expect(filterPeerDependencyIssues({
'.': {
missing: {
aaa: [
{
parents: [
{
name: 'xxx',
version: '1.0.0',
}],
optional: true,
wantedRange: '>=1.0.0 <3.0.0',
},
],
},
bad: {},
conflicts: [],
intersections: {},
},
}, {
allowAny: [],
})).toStrictEqual({
'.': {
bad: {},
conflicts: [],
intersections: {},
missing: {},
},
})
})