mirror of
https://github.com/pnpm/pnpm.git
synced 2026-04-12 02:57:44 -04:00
fix(print-peer-issues): escape the "*" range
This commit is contained in:
5
.changeset/eight-swans-notice.md
Normal file
5
.changeset/eight-swans-notice.md
Normal file
@@ -0,0 +1,5 @@
|
||||
---
|
||||
"@pnpm/render-peer-issues": patch
|
||||
---
|
||||
|
||||
When printing peer dependency issues, print the "\*" range in double quotes. This will make it easier to copy the package resolutions and put them to the end of a `pnpm add` command for execution.
|
||||
@@ -54,7 +54,7 @@ export default function (
|
||||
}
|
||||
|
||||
function formatNameAndRange (name: string, range: string) {
|
||||
if (range.includes(' ')) {
|
||||
if (range.includes(' ') || range === '*') {
|
||||
return `${name}@"${range}"`
|
||||
}
|
||||
return `${name}@${range}`
|
||||
|
||||
@@ -22,6 +22,15 @@ Peer dependencies that should be installed:
|
||||
ddd@^1.0.0 "
|
||||
`;
|
||||
|
||||
exports[`renderPeerIssues() format correctly the version ranges with spaces and "*" 1`] = `
|
||||
".
|
||||
└─┬ z
|
||||
├── ✕ missing peer a@\\"*\\"
|
||||
└── ✕ missing peer b@\\"1 || 2\\"
|
||||
Peer dependencies that should be installed:
|
||||
a@\\"*\\" b@\\"1 || 2\\" "
|
||||
`;
|
||||
|
||||
exports[`renderPeerIssues() optional peer dependencies are printed only if they are in conflict with non-optional peers 1`] = `
|
||||
".
|
||||
└─┬ xxx
|
||||
|
||||
@@ -160,3 +160,39 @@ test('renderPeerIssues() optional peer dependencies are printed only if they are
|
||||
},
|
||||
}, { width: 500 }))).toMatchSnapshot()
|
||||
})
|
||||
|
||||
test('renderPeerIssues() format correctly the version ranges with spaces and "*"', () => {
|
||||
expect(stripAnsi(renderPeerIssues({
|
||||
'.': {
|
||||
conflicts: [],
|
||||
intersections: { a: '*', b: '1 || 2' },
|
||||
bad: {},
|
||||
missing: {
|
||||
a: [
|
||||
{
|
||||
parents: [
|
||||
{
|
||||
name: 'z',
|
||||
version: '1.0.0',
|
||||
},
|
||||
],
|
||||
optional: false,
|
||||
wantedRange: '*',
|
||||
},
|
||||
],
|
||||
b: [
|
||||
{
|
||||
parents: [
|
||||
{
|
||||
name: 'z',
|
||||
version: '1.0.0',
|
||||
},
|
||||
],
|
||||
optional: false,
|
||||
wantedRange: '1 || 2',
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
}, { width: 500 }))).toMatchSnapshot()
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user