mirror of
https://github.com/pnpm/pnpm.git
synced 2026-05-11 09:28:24 -04:00
5
.changeset/lemon-rivers-happen.md
Normal file
5
.changeset/lemon-rivers-happen.md
Normal file
@@ -0,0 +1,5 @@
|
||||
---
|
||||
"@pnpm/list": patch
|
||||
---
|
||||
|
||||
Print the legend only once.
|
||||
1
fixtures/workspace-with-2-pkgs/package.json
Normal file
1
fixtures/workspace-with-2-pkgs/package.json
Normal file
@@ -0,0 +1 @@
|
||||
{}
|
||||
7
fixtures/workspace-with-2-pkgs/packages/bar/package.json
Normal file
7
fixtures/workspace-with-2-pkgs/packages/bar/package.json
Normal file
@@ -0,0 +1,7 @@
|
||||
{
|
||||
"name": "bar",
|
||||
"version": "0.0.0",
|
||||
"dependencies": {
|
||||
"is-positive": "1.0.0"
|
||||
}
|
||||
}
|
||||
8
fixtures/workspace-with-2-pkgs/packages/foo/package.json
Normal file
8
fixtures/workspace-with-2-pkgs/packages/foo/package.json
Normal file
@@ -0,0 +1,8 @@
|
||||
{
|
||||
"name": "foo",
|
||||
"version": "0.0.0",
|
||||
"dependencies": {
|
||||
"is-positive": "1.0.0"
|
||||
}
|
||||
}
|
||||
|
||||
21
fixtures/workspace-with-2-pkgs/pnpm-lock.yaml
generated
Normal file
21
fixtures/workspace-with-2-pkgs/pnpm-lock.yaml
generated
Normal file
@@ -0,0 +1,21 @@
|
||||
importers:
|
||||
.:
|
||||
specifiers: {}
|
||||
packages/bar:
|
||||
dependencies:
|
||||
is-positive: 1.0.0
|
||||
specifiers:
|
||||
is-positive: 1.0.0
|
||||
packages/foo:
|
||||
dependencies:
|
||||
is-positive: 1.0.0
|
||||
specifiers:
|
||||
is-positive: 1.0.0
|
||||
lockfileVersion: 5.1
|
||||
packages:
|
||||
/is-positive/1.0.0:
|
||||
dev: false
|
||||
engines:
|
||||
node: '>=0.10.0'
|
||||
resolution:
|
||||
integrity: sha1-iACYVrZKLx632LsBeUGEJK4EUss=
|
||||
2
fixtures/workspace-with-2-pkgs/pnpm-workspace.yaml
Normal file
2
fixtures/workspace-with-2-pkgs/pnpm-workspace.yaml
Normal file
@@ -0,0 +1,2 @@
|
||||
packages:
|
||||
- 'packages/**'
|
||||
@@ -26,7 +26,12 @@ export default async function (
|
||||
search: boolean,
|
||||
}
|
||||
) {
|
||||
return (await Promise.all(packages.map((pkg) => renderTreeForPackage(pkg, opts)))).filter(Boolean).join('\n\n')
|
||||
const output = (
|
||||
await Promise.all(packages.map((pkg) => renderTreeForPackage(pkg, opts)))
|
||||
)
|
||||
.filter(Boolean)
|
||||
.join('\n\n')
|
||||
return `${(opts.depth > -1 && output ? LEGEND : '')}${output}`
|
||||
}
|
||||
|
||||
async function renderTreeForPackage (
|
||||
@@ -55,7 +60,7 @@ async function renderTreeForPackage (
|
||||
label += ' '
|
||||
}
|
||||
label += pkg.path
|
||||
let output = (opts.depth > -1 ? LEGEND : '') + label + '\n'
|
||||
let output = `${label}\n`
|
||||
const useColumns = opts.depth === 0 && opts.long === false && !opts.search
|
||||
for (let dependenciesField of [...DEPENDENCIES_FIELDS.sort(), 'unsavedDependencies']) {
|
||||
if (pkg[dependenciesField]?.length) {
|
||||
|
||||
@@ -26,6 +26,7 @@ const fixture = path.join(fixtures, 'fixture')
|
||||
const fixtureWithNoPkgNameAndNoVersion = path.join(fixtures, 'fixture-with-no-pkg-name-and-no-version')
|
||||
const fixtureWithNoPkgVersion = path.join(fixtures, 'fixture-with-no-pkg-version')
|
||||
const fixtureWithExternalLockfile = path.join(fixtures, 'fixture-with-external-shrinkwrap', 'pkg')
|
||||
const workspaceWith2Pkgs = path.join(fixtures, 'workspace-with-2-pkgs')
|
||||
const emptyFixture = path.join(fixtures, 'empty')
|
||||
const fixtureWithAliasedDep = path.join(fixtures, 'with-aliased-dep')
|
||||
|
||||
@@ -42,6 +43,27 @@ is-positive ${VERSION_CLR('1.0.0')}`)
|
||||
t.end()
|
||||
})
|
||||
|
||||
test('print legend only once', async (t) => {
|
||||
t.equal(await list([
|
||||
path.join(workspaceWith2Pkgs, 'packages/bar'),
|
||||
path.join(workspaceWith2Pkgs, 'packages/foo'),
|
||||
], {
|
||||
lockfileDir: workspaceWith2Pkgs,
|
||||
}), `${LEGEND}
|
||||
|
||||
bar@0.0.0 ${path.join(workspaceWith2Pkgs, 'packages/bar')}
|
||||
|
||||
${DEPENDENCIES}
|
||||
is-positive ${VERSION_CLR('1.0.0')}
|
||||
|
||||
foo@0.0.0 ${path.join(workspaceWith2Pkgs, 'packages/foo')}
|
||||
|
||||
${DEPENDENCIES}
|
||||
is-positive ${VERSION_CLR('1.0.0')}`)
|
||||
|
||||
t.end()
|
||||
})
|
||||
|
||||
test('list with default parameters', async t => {
|
||||
t.equal(await list([fixture], { lockfileDir: fixture }), `${LEGEND}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user