Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(outdated): fixed wanted range for alias with version range #7595

Merged
merged 1 commit into from
Jun 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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)
})
Loading