Skip to content

[BUG] npm outdated exit code should not be set with json output #3844

@wraithgar

Description

@wraithgar

Is there an existing issue for this?

  • I have searched the existing issues

Current Behavior

See #1109

Fix will be.

diff --git a/lib/outdated.js b/lib/outdated.js
index b3b630421..68002bf19 100644
--- a/lib/outdated.js
+++ b/lib/outdated.js
@@ -88,13 +88,14 @@ class Outdated extends ArboristWorkspaceCmd {
     // sorts list alphabetically
     const outdated = this.list.sort((a, b) => localeCompare(a.name, b.name))
 
-    if (outdated.length > 0)
-      process.exitCode = 1
-
     // return if no outdated packages
     if (outdated.length === 0 && !this.npm.config.get('json'))
       return
 
+    if (!this.npm.config.get('json'))
+      process.exitCode = 1
+
+

Expected Behavior

No response

Steps To Reproduce

No response

Environment

  • npm: 7.24.2

Metadata

Metadata

Assignees

Labels

Bugthing that needs fixingNeeds Discussionis pending a discussionRelease 7.xwork is associated with a specific npm 7 release

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions