check.js 668 B

12345678910111213141516171819202122
  1. /* eslint-disable unicorn/no-process-exit */
  2. 'use strict';
  3. var updateNotifier = require('./');
  4. var options = JSON.parse(process.argv[2]);
  5. updateNotifier = new updateNotifier.UpdateNotifier(options);
  6. updateNotifier.checkNpm().then(function (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 nodejs docs)
  14. process.exit();
  15. }).catch(function () {
  16. process.exit(1);
  17. });