check.js 659 B

12345678910111213141516171819202122
  1. /* eslint-disable unicorn/no-process-exit */
  2. 'use strict';
  3. let updateNotifier = require('.');
  4. const options = JSON.parse(process.argv[2]);
  5. updateNotifier = new updateNotifier.UpdateNotifier(options);
  6. updateNotifier.checkNpm().then(update => {
  7. // Only update the last update check time on success
  8. updateNotifier.config.set('lastUpdateCheck', Date.now());
  9. if (update.type && update.type !== 'latest') {
  10. updateNotifier.config.set('update', update);
  11. }
  12. // Call process exit explicitly to terminate the child process
  13. // Otherwise the child process will run forever, according to the Node.js docs
  14. process.exit();
  15. }).catch(() => {
  16. process.exit(1);
  17. });