Skip to content

Commit

Permalink
fix(outdated): fixed wanted range for alias with version range (#7595)
Browse files Browse the repository at this point in the history
Fix: #7573
  • Loading branch information
milaninfy committed Jun 14, 2024
1 parent 71c6848 commit 2273183
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/commands/outdated.js
Original file line number Diff line number Diff line change
Expand Up @@ -153,8 +153,8 @@ class Outdated extends ArboristWorkspaceCmd {
}

async #getOutdatedInfo (edge) {
const alias = safeNpa(edge.spec)?.subSpec?.name
const spec = npa(alias ?? edge.name)
const alias = safeNpa(edge.spec)?.subSpec
const spec = npa(alias ? alias.name : edge.name)
const node = edge.to || edge
const { path, location, package: { version: current } = {} } = node

Expand Down
5 changes: 5 additions & 0 deletions tap-snapshots/test/lib/commands/outdated.js.test.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@ Package Current Wanted Latest Location Depended by
cat:dog@latest 1.0.0 2.0.0 2.0.0 node_modules/cat prefix
`

exports[`test/lib/commands/outdated.js TAP aliases with version range > should display aliased outdated dep output with correct wanted values 1`] = `
Package Current Wanted Latest Location Depended by
cat:dog@^1.0.0 1.0.0 1.0.1 2.0.0 node_modules/cat prefix
`

exports[`test/lib/commands/outdated.js TAP should display outdated deps outdated --all > must match snapshot 1`] = `
Package Current Wanted Latest Location Depended by
cat 1.0.0 1.0.1 1.0.1 node_modules/cat prefix
Expand Down
31 changes: 31 additions & 0 deletions test/lib/commands/outdated.js
Original file line number Diff line number Diff line change
Expand Up @@ -631,3 +631,34 @@ t.test('aliases', async t => {
t.matchSnapshot(joinedOutput(), 'should display aliased outdated dep output')
t.equal(process.exitCode, 1)
})

t.test('aliases with version range', async t => {
const testDir = {
'package.json': JSON.stringify({
name: 'display-aliases',
version: '1.0.0',
dependencies: {
cat: 'npm:dog@^1.0.0',
},
}),
node_modules: {
cat: {
'package.json': JSON.stringify({
name: 'dog',
version: '1.0.0',
}),
},
},
}

const { outdated, joinedOutput } = await mockNpm(t, {
prefixDir: testDir,
})
await outdated.exec([])

t.matchSnapshot(
joinedOutput(),
'should display aliased outdated dep output with correct wanted values'
)
t.equal(process.exitCode, 1)
})

0 comments on commit 2273183

Please sign in to comment.