Skip to content
This repository was archived by the owner on Aug 11, 2022. It is now read-only.

outdated: exitcode != 0 on outdated dependencies#14013

Closed
watilde wants to merge 1 commit intonpm:masterfrom
watilde:outdated-exit-1
Closed

outdated: exitcode != 0 on outdated dependencies#14013
watilde wants to merge 1 commit intonpm:masterfrom
watilde:outdated-exit-1

Conversation

@watilde
Copy link
Contributor

@watilde watilde commented Sep 19, 2016

Fixes: #5999.

This update is a breaking change requested a long time ago. When outdated dependencies exist in a project, the command displays a helpful error message and then finish the action with exit 1. To ignore the error and keep the previous behavior, it's possible via passing --silent option.

@othiym23 othiym23 added this to the 4.x milestone Sep 19, 2016
This update is a breaking change feature. When outdated dependencies
exist in a project, the command displays a helpful error message
and then finish the action with `exit 1`. To ignore the error and
keep the previous behavior, it's possible via passing `--silent` option.

Fixes: npm#5999
PR-URL: npm#14013
Credit: @watilde
Reviewed-By: @
Copy link
Contributor

@iarna iarna left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For the record: this all looks good. We'll be including it in npm@4.

'the versions in node_module, or look over package.json',
'to use the most suitable semver range.'
].join('\n')
cb(msg, list.map(function (item) { return [item[0].parent.path].concat(item.slice(1, 7)) }))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Quick question – should the first arg here be an Error instead of a String? (not sure about npm's style preference – but most Node.js projects typically use Errors so that stack information is retained, among other things)

Copy link
Contributor

@iarna iarna Oct 20, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Errors from commands (like this one) are processed via lib/utils/error-handler.js, which, if the error argument is a string, prints it to the user using log.error and exits with a non-zero exit code.

By contrast, if we called back with an error object (which we often do), then its output message is determined via lib/utils/error-message.js and it's logged along with a bunch of other diagnostic information.

This is actually the only way currently to trigger a non-zero exit code without printing all sorts of diagnostic information on folks screens.

If I were to design our error handling, I'd have it ONLY accept error objects and use an error class to use for this kind of scenario. But IMO that kind of rewrite (while positive) is out of scope for this PR and so I wouldn't ask someone contributing a change like this one to make that kind of rewrite.

zkat pushed a commit that referenced this pull request Oct 20, 2016
This update is a breaking change feature. When outdated dependencies
exist in a project, the command displays a helpful error message
and then finish the action with `exit 1`. To ignore the error and
keep the previous behavior, it's possible via passing `--silent` option.

Fixes: #5999
PR-URL: #14013
Credit: @watilde
Reviewed-By: @zkat
Reviewed-By: @iarna
zkat added a commit that referenced this pull request Oct 20, 2016
zkat added a commit that referenced this pull request Oct 20, 2016
PR-URL: #14013
Credit: @zkat
Reviewed-By: @iarna
zkat added a commit that referenced this pull request Oct 20, 2016
zkat added a commit that referenced this pull request Oct 20, 2016
PR-URL: #14013
Credit: @zkat
Reviewed-By: @iarna
@zkat
Copy link
Contributor

zkat commented Oct 20, 2016

This was merged into release-next!

We had some discussion at the last minute about the UX for this and I ended up making some quick patches on top of what you did in a separate PR, btw. If we'd had more time pre-npm@4 we would've done it in review though. ^_^;;

This is really great, though, @watilde! Thank you as always for the excellent work <3

@zkat zkat closed this Oct 20, 2016
@watilde watilde deleted the outdated-exit-1 branch January 5, 2017 10:52
@fearphage
Copy link

FYI, I don't see tests for --silent nor can I get it to work as expected.

➜  unity git:(starting-point) ✗ node --version
v7.7.1
➜  unity git:(starting-point) ✗ npm --version
4.1.2
➜  unity git:(starting-point) ✗ npm outdated > /dev/null; echo $?
1
➜  unity git:(starting-point) ✗ npm outdated --silent > /dev/null; echo $?
1
➜  unity git:(starting-point) ✗ npm --slient outdated > /dev/null; echo $?       
1
➜  unity git:(starting-point) ✗ npm --slient outdated --silent > /dev/null; echo $?
1

Am I missing something?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants