Open khalyomede opened 2 years ago
Right now, npm outdated --json
is really hard to use because of that non-zero error status it returns; all of the sync-exec variants of Node's stdlib raise in that case, which means that the output cannot be recovered without doing unholy things (redirect to tmp, execute, read from tmp, delete tmp), and the alternative of using the promisified-exec variant isn't exactly viable if the check happens deep inside low-level code and would need a lot of functions to be async-recolored.
As I said in #473, I'd add an npm outdated --check
that returns 1 and no output if there are outdated dependencies, for the purpose of tooling that only cares about whether everything is up-to-date — vs. me who wants the list of what isn't updated and act on it programmatically.
So the error return would be:
--check
is passed and there are outdated packages installed, return 1,I guess an alternative, preserving the current behavior, would be a flag like --silent
, but --json --silent
and expecting output to parse feels… weird. Or even just making --json
always return 0, because otherwise you can only ever get {}
or an error thrown.
Motivation ("The Why")
Using NPM, we can check for outdated packages:
I also have a CI that is running everytime I push a commit on the main branch, and will check for missing updates to pull. Unfortunately, no flags exists to make this command to return a non zero code when it finds outdated packages.
Example
I suggest to have a new
--ci
flag (inspired bynpm ci
command), to make the outdated check to return a non-zero code when some packages have been found for greater versions.How
Current Behaviour
No flags exist to return a non-zero code.
Desired Behaviour
An flag is available to return a non-zero code.
References
Split from
https://github.com/npm/cli/issues/5208
Existing arts
Composer (PHP) is providing a flag for it behind the
--strict
flag: