Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/npm/cli.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/commands/outdated.js11
-rw-r--r--tap-snapshots/test/lib/commands/outdated.js.test.cjs6
-rw-r--r--test/lib/commands/outdated.js25
3 files changed, 39 insertions, 3 deletions
diff --git a/lib/commands/outdated.js b/lib/commands/outdated.js
index e1a6f8150..0cb5b4247 100644
--- a/lib/commands/outdated.js
+++ b/lib/commands/outdated.js
@@ -193,7 +193,12 @@ class Outdated extends ArboristWorkspaceCmd {
}
async getOutdatedInfo (edge) {
- const spec = npa(edge.name)
+ let alias = false
+ try {
+ alias = npa(edge.spec).subSpec
+ } catch (err) {
+ }
+ const spec = npa(alias ? alias.name : edge.name)
const node = edge.to || edge
const { path, location } = node
const { version: current } = node.package || {}
@@ -217,7 +222,7 @@ class Outdated extends ArboristWorkspaceCmd {
try {
const packument = await this.getPackument(spec)
- const expected = edge.spec
+ const expected = alias ? alias.fetchSpec : edge.spec
// if it's not a range, version, or tag, skip it
try {
if (!npa(`${edge.name}@${edge.spec}`).registry) {
@@ -239,7 +244,7 @@ class Outdated extends ArboristWorkspaceCmd {
: 'global'
this.list.push({
- name: edge.name,
+ name: alias ? edge.spec.replace('npm', edge.name) : edge.name,
path,
type,
current,
diff --git a/tap-snapshots/test/lib/commands/outdated.js.test.cjs b/tap-snapshots/test/lib/commands/outdated.js.test.cjs
index c286ad734..ef6baa966 100644
--- a/tap-snapshots/test/lib/commands/outdated.js.test.cjs
+++ b/tap-snapshots/test/lib/commands/outdated.js.test.cjs
@@ -5,6 +5,12 @@
* Make sure to inspect the output below. Do not ignore changes!
*/
'use strict'
+exports[`test/lib/commands/outdated.js TAP aliases > should display aliased outdated dep output 1`] = `
+
+Package Current Wanted Latest Location Depended by
+cat:dog@latest 1.0.0 2.0.0 2.0.0 node_modules/cat tap-testdir-outdated-aliases
+`
+
exports[`test/lib/commands/outdated.js TAP should display outdated deps outdated --all > must match snapshot 1`] = `
Package Current Wanted Latest Location Depended by
diff --git a/test/lib/commands/outdated.js b/test/lib/commands/outdated.js
index 245e93039..3bf42b10a 100644
--- a/test/lib/commands/outdated.js
+++ b/test/lib/commands/outdated.js
@@ -609,3 +609,28 @@ t.test('workspaces', async t => {
t.matchSnapshot(logs,
'should display missing deps when filtering by ws')
})
+
+t.test('aliases', async t => {
+ const testDir = t.testdir({
+ 'package.json': JSON.stringify({
+ name: 'display-aliases',
+ version: '1.0.0',
+ dependencies: {
+ cat: 'npm:dog@latest',
+ },
+ }),
+ node_modules: {
+ cat: {
+ 'package.json': JSON.stringify({
+ name: 'dog',
+ version: '1.0.0',
+ }),
+ },
+ },
+ })
+
+ await outdated(testDir, {}).exec([])
+
+ t.matchSnapshot(logs, 'should display aliased outdated dep output')
+ t.equal(process.exitCode, 1)
+})