-
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
cli: don't run update-notifier in CI environment #33
Conversation
Nice one @sibiraj-s. This and #32 will make the update-notifier work the same as pnpm |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So far so good! Thanks a bunch for submitting this PR, and welcome! Just a couple of changes and I think this is ready to go. 🎉
bin/npm-cli.js
Outdated
@@ -80,9 +80,10 @@ | |||
) { | |||
const pkg = require('../package.json') | |||
let notifier = require('update-notifier')({pkg}) | |||
const isCI = require('is-ci') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd rather use ci-info
, since it's what is-ci
itself uses. We don't need yet another package.json floating around for a one-liner by the same author. ci-info
exports an isCI
property that you can achieve the same thing with.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@zkat . It seems is-ci
is already a part of this package(a dependant of update-notifier). having that now won't make a difference?
bin/npm-cli.js
Outdated
if ( | ||
notifier.update && | ||
notifier.update.latest !== pkg.version | ||
notifier.update.latest !== pkg.version && !isCI |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do you mind putting this on the next line for consistency?
package.json
Outdated
@@ -177,6 +178,7 @@ | |||
"inherits", | |||
"ini", | |||
"init-package-json", | |||
"is-ci", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome! You added it to bundleDependencies
. Additionally, we commit our dependencies, and we use package-lock.json
so please go ahead and git add -A node_modules/ package-lock.json
as well before you commit the ci-info
change I asked for above!
@@ -80,9 +80,11 @@ | |||
) { | |||
const pkg = require('../package.json') | |||
let notifier = require('update-notifier')({pkg}) | |||
const isCI = require('ci-info').isCI |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We already detect CI in a handful of places and currently ci-info
doesn't entirely align. Then again, our various detectors don't align with each other. Ideally, I'd like to see those patched to use ci-info
as well (but not in this PR).
For reference, our existing CI detectors are here:
Line 194 in ab3c62a
'progress': !process.env.TRAVIS && !process.env.CI, |
and here:
The latter one detects things ci-info
doesn't, so ci-info
will need patching before we can entirely switch over to it.
There's also:
Which should probably be patched too, though we aren't/won't be using it any more in npm proper.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
BTW: The is-ci
module is just a convenience wrapper around ci-info
, that when used programmatically returns a boolean and when used from the command line uses the exit code to signal if it's being run on a CI server or not.
package.json
Outdated
@@ -45,6 +45,7 @@ | |||
"cacache": "^11.0.2", | |||
"call-limit": "~1.1.0", | |||
"chownr": "~1.0.1", | |||
"ci-info": "^1.1.3", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's still no package-lock.json
change in this PR? We'll need that to land this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@iarna I got it. The ci-info
is already used as a dependecy of update-notifier
update-notifier -> is-ci -> ci-info
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ohhhhh
that makes sense.
@iarna . I raised a PR in |
Once @watson gets around to reviewing/approving the |
As a note for @iarna: I think it's fine and pretty much safe that Additional note to self: I should probably patch |
@zkat Thanks a lot of pinging me on this. I'm so bad at checking github notifications - have a huge backlog 😬 |
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 looks good! Thank you @watson and @sibiraj-s!
PR-URL: #33 Credit: @sibiraj-s Reviewed-By: @zkat
PR-URL: #33 Credit: @sibiraj-s Reviewed-By: @zkat
I merged this manually, so github isn't gonna detect it as a merge, but this is now in |
PR-URL: #33 Credit: @sibiraj-s Reviewed-By: @zkat
PR-URL: #33 Credit: @sibiraj-s Reviewed-By: @zkat
cool. @zkat I would also suggest to update ci-info to v1.4 before the release, as it detects two more popular CI's |
This is a followup to npm#33 that changes the logic to literally *not* run update-notifier in CI environment, instead of running it and omitting the result.
This Prevents update notifier from running in CI environment