Skip to content

Commit 1a9409c

Browse files
committedFeb 10, 2025·
fix(outdated): add dependent location in long output
1 parent 3a80a7b commit 1a9409c

File tree

2 files changed

+23
-13
lines changed

2 files changed

+23
-13
lines changed
 

Diff for: ‎lib/commands/outdated.js

+10-4
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,9 @@ class Outdated extends ArboristWorkspaceCmd {
195195
wanted: wanted.version,
196196
latest: latest.version,
197197
workspaceDependent: edge.from?.isWorkspace ? edge.from.pkgid : null,
198+
dependentLocation: edge.from?.name
199+
? edge.from?.location
200+
: 'global',
198201
dependent: edge.from?.name ?? 'global',
199202
homepage: packument.homepage,
200203
})
@@ -226,7 +229,7 @@ class Outdated extends ArboristWorkspaceCmd {
226229
'Latest',
227230
'Location',
228231
'Depended by',
229-
...long ? ['Package Type', 'Homepage'] : [],
232+
...long ? ['Package Type', 'Homepage', 'Dependent Location'] : [],
230233
].map(h => bold.underline(h)),
231234
...list.map((d) => [
232235
d.current === d.wanted ? yellow(d.name) : red(d.name),
@@ -235,7 +238,7 @@ class Outdated extends ArboristWorkspaceCmd {
235238
blue(d.latest),
236239
d.location ?? '-',
237240
d.workspaceDependent ? blue(d.workspaceDependent) : d.dependent,
238-
...long ? [d.type, blue(d.homepage ?? '')] : [],
241+
...long ? [d.type, blue(d.homepage ?? ''), d.dependentLocation] : [],
239242
]),
240243
], {
241244
align: ['l', 'r', 'r', 'r', 'l'],
@@ -252,7 +255,7 @@ class Outdated extends ArboristWorkspaceCmd {
252255
d.current ? `${d.name}@${d.current}` : 'MISSING',
253256
`${d.name}@${d.latest}`,
254257
d.dependent,
255-
...this.npm.config.get('long') ? [d.type, d.homepage] : [],
258+
...this.npm.config.get('long') ? [d.type, d.homepage, d.dependentLocation] : [],
256259
].join(':')).join('\n')
257260
}
258261

@@ -268,7 +271,10 @@ class Outdated extends ArboristWorkspaceCmd {
268271
latest: d.latest,
269272
dependent: d.dependent,
270273
location: d.path,
271-
...this.npm.config.get('long') ? { type: d.type, homepage: d.homepage } : {},
274+
...this.npm.config.get('long') ? {
275+
type: d.type,
276+
homepage: d.homepage,
277+
dependentLocation: d.dependentLocation } : {},
272278
}
273279
acc[d.name] = acc[d.name]
274280
// If this item alread has an outdated dep then we turn it into an array

Diff for: ‎tap-snapshots/test/lib/commands/outdated.js.test.cjs

+13-9
Original file line numberDiff line numberDiff line change
@@ -31,29 +31,33 @@ exports[`test/lib/commands/outdated.js TAP should display outdated deps outdated
3131
"latest": "1.0.1",
3232
"dependent": "prefix",
3333
"location": "{CWD}/prefix/node_modules/cat",
34-
"type": "dependencies"
34+
"type": "dependencies",
35+
"dependentLocation": ""
3536
},
3637
"chai": {
3738
"current": "1.0.0",
3839
"wanted": "1.0.1",
3940
"latest": "1.0.1",
4041
"dependent": "prefix",
4142
"location": "{CWD}/prefix/node_modules/chai",
42-
"type": "peerDependencies"
43+
"type": "peerDependencies",
44+
"dependentLocation": ""
4345
},
4446
"dog": {
4547
"current": "1.0.1",
4648
"wanted": "1.0.1",
4749
"latest": "2.0.0",
4850
"dependent": "prefix",
4951
"location": "{CWD}/prefix/node_modules/dog",
50-
"type": "dependencies"
52+
"type": "dependencies",
53+
"dependentLocation": ""
5154
},
5255
"theta": {
5356
"wanted": "1.0.1",
5457
"latest": "1.0.1",
5558
"dependent": "prefix",
56-
"type": "dependencies"
59+
"type": "dependencies",
60+
"dependentLocation": ""
5761
}
5862
}
5963
`
@@ -90,7 +94,7 @@ exports[`test/lib/commands/outdated.js TAP should display outdated deps outdated
9094
`
9195

9296
exports[`test/lib/commands/outdated.js TAP should display outdated deps outdated --long > must match snapshot 1`] = `
93-
Package Current Wanted Latest Location Depended by Package Type Homepage
97+
Package Current Wanted Latest Location Depended by Package Type Homepage Dependent Location
9498
cat 1.0.0 1.0.1 1.0.1 node_modules/cat prefix dependencies
9599
chai 1.0.0 1.0.1 1.0.1 node_modules/chai prefix peerDependencies
96100
dog 1.0.1 1.0.1 2.0.0 node_modules/dog prefix dependencies
@@ -120,10 +124,10 @@ exports[`test/lib/commands/outdated.js TAP should display outdated deps outdated
120124
`
121125

122126
exports[`test/lib/commands/outdated.js TAP should display outdated deps outdated --parseable --long > must match snapshot 1`] = `
123-
{CWD}/prefix/node_modules/cat:cat@1.0.1:cat@1.0.0:cat@1.0.1:prefix:dependencies:
124-
{CWD}/prefix/node_modules/chai:chai@1.0.1:chai@1.0.0:chai@1.0.1:prefix:peerDependencies:
125-
{CWD}/prefix/node_modules/dog:dog@1.0.1:dog@1.0.1:dog@2.0.0:prefix:dependencies:
126-
:theta@1.0.1:MISSING:theta@1.0.1:prefix:dependencies:
127+
{CWD}/prefix/node_modules/cat:cat@1.0.1:cat@1.0.0:cat@1.0.1:prefix:dependencies::
128+
{CWD}/prefix/node_modules/chai:chai@1.0.1:chai@1.0.0:chai@1.0.1:prefix:peerDependencies::
129+
{CWD}/prefix/node_modules/dog:dog@1.0.1:dog@1.0.1:dog@2.0.0:prefix:dependencies::
130+
:theta@1.0.1:MISSING:theta@1.0.1:prefix:dependencies::
127131
`
128132

129133
exports[`test/lib/commands/outdated.js TAP should display outdated deps outdated --parseable > must match snapshot 1`] = `

0 commit comments

Comments
 (0)