-
Notifications
You must be signed in to change notification settings - Fork 3.2k
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
[BUG] npm outdated --json
only lists a single entry for each package, producing less than without --json
#6630
Closed
2 tasks done
Labels
Comments
asos-tomp
added
Bug
thing that needs fixing
Needs Triage
needs review for next steps
Release 9.x
work is associated with a specific npm 9 release
labels
Jul 6, 2023
For the final suggestion, could modify makeJSON (list) {
const out = {}
list.forEach(dep => {
const {
name,
current,
wanted,
latest,
path,
type,
dependent,
homepage,
} = dep
out[dependent] = {
...out[dependent],
[name]: {
current,
wanted,
latest,
location: path,
}
}
if (this.npm.config.get('long')) {
out[dependent][name] = {
...out[dependent][name],
type,
homepage,
}
}
})
return JSON.stringify(out, null, 2)
} ...or perhaps using reduce: makeJSON (list) {
const out = list.reduce(
(
list,
{
name,
current,
wanted,
latest,
path: location,
type,
dependent,
homepage
}
) => ({
...list,
[dependent]: {
...list[dependent],
[name]: {
current,
wanted,
latest,
location,
...(this.npm.config.get('long')
? {
type,
homepage
}
: {})
}
}
}),
{}
);
return JSON.stringify(out, null, 2)
} |
lukekarrys
added
config:display
Issues dealing with display of data to terminal
and removed
Needs Triage
needs review for next steps
Release 9.x
work is associated with a specific npm 9 release
labels
May 11, 2024
lukekarrys
added a commit
that referenced
this issue
May 16, 2024
lukekarrys
added a commit
that referenced
this issue
May 16, 2024
lukekarrys
added a commit
that referenced
this issue
May 16, 2024
lukekarrys
added a commit
that referenced
this issue
May 16, 2024
lukekarrys
added a commit
that referenced
this issue
May 16, 2024
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
Is there an existing issue for this?
This issue exists in the latest npm version
Current Behavior
npm outdated
in a project with workspaces can produce:...but when doing
npm outdated --json
, only details of the last dependent is shown:Hence, seems like whatever reducer is producing the json is flattening to the last dependent, rather than providing a full list that would be available without
--json
.To get around this, one must call
npm outdated --json --workspace=xxx
for each workspace, then consolidate the results. Presumably the--json
option shouldn't produce less information than the tabular format?Expected Behavior
Either the output needs to include an array per dependency:
..or if "dependent" isn't needed in the output as a key, just key a map by dependent:
Steps To Reproduce
npm outdated --json
with a project that includesworkspaces
(with or without the--workspaces
flag)Environment
The text was updated successfully, but these errors were encountered: