raineorshine / npm-check-updates

Find newer versions of package dependencies than what your package.json allows
Other
9.35k stars 323 forks source link

[Question] Is there a way to disable the upgrade notice? #1324

Open wenfangdu opened 1 year ago

wenfangdu commented 1 year ago

How do you disable the following message? Also, I'm using pnpm, it always suggests doing npm i -g npm-check-updates, which is wrong.

image

raineorshine commented 1 year ago

There is not a way to disable the update-notifier currently, though I could add an environment variable for that.

As for your second question about the package manager, I'll have to look into that to see if it's possible. That message is coming from a library that handles the update logic and notification.

raineorshine commented 1 year ago

I reviewed update-notifier and discovered that it does not run when executed within an npm script. Try creating a simple npm script "ncu": "ncu". Then you should be able to do npm run ncu and check for updates without getting the update-notifier message. Let me know if that works for you.

When it comes to the npm install command it suggests, that appears to be a limitation of update-notifier itself. It only detects npm or yarn. It is currently using a simple is-yarn-global package to detect yarn, and maybe something similar can be done for pnpm. I suggest opening an issue on the update-notifier repo to request this functionality, or even better a PR.

wenfangdu commented 1 year ago

I suggest opening an issue on the update-notifier repo to request this functionality.

Tracked here.

alex-kinokon commented 9 months ago

@raineorshine Would you mind vendoring update-notifier? It’s a small package and they dropped support for yarn after being asked to support pnpm.

raineorshine commented 9 months ago

What do you mean by vendoring?

alex-kinokon commented 9 months ago

Inlining their source code and modify it to fit our needs in this repo.

raineorshine commented 9 months ago

Got it, thanks.

Even easier, we can replace this line:

https://github.com/raineorshine/npm-check-updates/blob/be4b557d3da1f118ca3e7286fc34ab106fdb10ed/src/bin/cli.ts#L61

with our own template literal:

Run ${chalk.cyan(`${options.packageManager} ${options.packageManager ==='yarn' ? 'add' : 'install'}${options.global ? ' -g' : ''} npm-check-updates`)} to update

That's basically what update-notifier is doing, but with the package manager specific phrasing added.

alex-kinokon commented 1 month ago

Would you accept a PR for this?

raineorshine commented 1 month ago

For an environment variable to disable update-notifier? Yes.

Let me know if you had something else in mind though.

alex-kinokon commented 1 month ago

No I mean supporting different package managers.

raineorshine commented 1 month ago

Yes! Sure.