npm / npme-installer

npm Enterprise installer
https://www.npmjs.com/enterprise
Other
35 stars 21 forks source link

Do not let update-notifier errors crash the bin #132

Closed nexdrew closed 8 years ago

nexdrew commented 8 years ago

Found problem testing 3.7.0 with update-notifier file permissions. This is somewhat of an ugly hack fix to handle cases of running the npme bin between sudo/root and non-root users.

  1. Silently ignore errors (fs permission problems against ~/.config/configstore/update-notifier-npme.json file) when running update-notifier
  2. Do not run update-notifier on prescribed installation (sudo npm i -g npme --unsafe) by using a hidden alias of the install command for the postinstall script
  3. Customize the update-notifier update message to say sudo npm i -g instead of npm i -g

The goal of item 2 is to check for updates when running the bin with valid non-autoinstall command (by decorating each command builder function) or with invalid/missing command (via custom yargs failure handler and strict mode).

I have tested this on an existing instance that already had npmo/npme installed, but I still need to test it against a fresh install instance. Will do that via next tag after merging this.

nexdrew commented 8 years ago

Instead of silently ignoring the update-notifier crash, I opted to print a banner about the failure instead, with a note about how to fix it:

screen shot 2016-04-28 at 11 46 03 am

I'm not crazy about it, but I think keeping npme up-to-date is worth the annoyance.