Skip to content

Commit 2273183

Browse files
authored
fix(outdated): fixed wanted range for alias with version range (#7595)
Fix: #7573
1 parent 71c6848 commit 2273183

File tree

3 files changed

+38
-2
lines changed

3 files changed

+38
-2
lines changed

lib/commands/outdated.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -153,8 +153,8 @@ class Outdated extends ArboristWorkspaceCmd {
153153
}
154154

155155
async #getOutdatedInfo (edge) {
156-
const alias = safeNpa(edge.spec)?.subSpec?.name
157-
const spec = npa(alias ?? edge.name)
156+
const alias = safeNpa(edge.spec)?.subSpec
157+
const spec = npa(alias ? alias.name : edge.name)
158158
const node = edge.to || edge
159159
const { path, location, package: { version: current } = {} } = node
160160

tap-snapshots/test/lib/commands/outdated.js.test.cjs

+5
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,11 @@ Package Current Wanted Latest Location Depended by
1010
cat:dog@latest 1.0.0 2.0.0 2.0.0 node_modules/cat prefix
1111
`
1212

13+
exports[`test/lib/commands/outdated.js TAP aliases with version range > should display aliased outdated dep output with correct wanted values 1`] = `
14+
Package Current Wanted Latest Location Depended by
15+
cat:dog@^1.0.0 1.0.0 1.0.1 2.0.0 node_modules/cat prefix
16+
`
17+
1318
exports[`test/lib/commands/outdated.js TAP should display outdated deps outdated --all > must match snapshot 1`] = `
1419
Package Current Wanted Latest Location Depended by
1520
cat 1.0.0 1.0.1 1.0.1 node_modules/cat prefix

test/lib/commands/outdated.js

+31
Original file line numberDiff line numberDiff line change
@@ -631,3 +631,34 @@ t.test('aliases', async t => {
631631
t.matchSnapshot(joinedOutput(), 'should display aliased outdated dep output')
632632
t.equal(process.exitCode, 1)
633633
})
634+
635+
t.test('aliases with version range', async t => {
636+
const testDir = {
637+
'package.json': JSON.stringify({
638+
name: 'display-aliases',
639+
version: '1.0.0',
640+
dependencies: {
641+
cat: 'npm:dog@^1.0.0',
642+
},
643+
}),
644+
node_modules: {
645+
cat: {
646+
'package.json': JSON.stringify({
647+
name: 'dog',
648+
version: '1.0.0',
649+
}),
650+
},
651+
},
652+
}
653+
654+
const { outdated, joinedOutput } = await mockNpm(t, {
655+
prefixDir: testDir,
656+
})
657+
await outdated.exec([])
658+
659+
t.matchSnapshot(
660+
joinedOutput(),
661+
'should display aliased outdated dep output with correct wanted values'
662+
)
663+
t.equal(process.exitCode, 1)
664+
})

0 commit comments

Comments
 (0)