yeoman / update-notifier

Update notifications for your CLI app
BSD 2-Clause "Simplified" License
1.76k stars 132 forks source link

[FR] Support pnpm #231

Closed wenfangdu closed 1 year ago

wenfangdu commented 1 year ago

Currently, update-notifier only detects npm or yarn. It is currently using a simple is-yarn-global package to detect yarn, adding support for pnpm would be nice.

sindresorhus commented 1 year ago

I decided to drop the alternative package manager commands. Now it's only npm.

https://github.com/yeoman/update-notifier/commit/a1d8d9d9150d00dbc908820dc3fe8b33bac3003a

karlhorky commented 4 months ago

@sindresorhus Hm, why did you decide to drop the alternative package manager commands?

This is actually an incorrect command for a package globally installed by pnpm:

It suggests installing it locally, which is

  1. Probably not what the user wants
  2. Not even possible in this package because packageManager is set to pnpm - this command will result in an error
$ np

...

   ╭───────────────────────────────────────╮
   │                                       │
   │   Update available 10.0.5 → 10.0.6    │
   │        Run npm i np to update         │
   │                                       │
   ╰───────────────────────────────────────╯

$ ls -al $(which np)
-rwxr-xr-x  1 k  staff   1.0K Jun 20 17:44 /Users/k/Library/pnpm/np # Global installation in pnpm

Also, as np received pnpm support now, it's a bit of a bumpy experience, when everything else is running with pnpm.

sindresorhus commented 4 months ago

It's explained in the commit message.

karlhorky commented 4 months ago

Ok thanks, so it's because:

  1. Yarn / alternative package manager users should know which commands to run
  2. You don't want to maintain the list

Mostly makes sense, although I would take issue with 1., considering many beginners will not have an idea about this, and they will also be using alternative package managers in many companies / projects that they will be a part of.

For 2, if there was a package available that took over maintenance of the commands for all of them, would it be acceptable to revert this change and add pnpm and Bun support? (npm, Yarn, pnpm, Bun)