feat(list): add workspace to list command when setting output to json (#3432)

when running pnpm list  with --json flag for each workspace print the path in the json output

closes #3418

Co-authored-by: Zoltan Kochan <zkochan@users.noreply.github.com>
This commit is contained in:
amit
2021-05-10 01:47:16 +04:00
committed by GitHub
parent a7de89feb4
commit 6f3fa2233e
3 changed files with 9 additions and 5 deletions

View File

@@ -0,0 +1,5 @@
---
"@pnpm/list": minor
---
Feat - add path as part of list command json output

View File

@@ -17,8 +17,8 @@ export default async function (
const jsonArr = await Promise.all(pkgs.map(async (pkg) => {
const jsonObj = {
name: pkg.name,
version: pkg.version,
path: pkg.path,
}
for (const dependenciesField of [...DEPENDENCIES_FIELDS.sort(), 'unsavedDependencies']) {
if (pkg[dependenciesField]?.length) {

View File

@@ -245,7 +245,7 @@ test('JSON list with depth 1', async () => {
expect(await list([fixture], { reportAs: 'json', depth: 1, lockfileDir: fixture })).toBe(JSON.stringify([{
name: 'fixture',
version: '1.0.0',
path: fixture,
dependencies: {
'write-json-file': {
from: 'write-json-file',
@@ -320,12 +320,11 @@ test('JSON list with aliased dep', async () => {
{
name: 'with-aliased-dep',
version: '1.0.0',
path: fixtureWithAliasedDep,
dependencies: {
positive: {
from: 'is-positive',
version: '1.0.0',
resolved: 'https://registry.npmjs.org/is-positive/-/is-positive-1.0.0.tgz',
},
},
@@ -338,7 +337,7 @@ test('JSON list with aliased dep', async () => {
JSON.stringify([{
name: 'with-aliased-dep',
version: '1.0.0',
path: fixtureWithAliasedDep,
dependencies: {
positive: {
from: 'is-positive',