UNPKG

780 BJavaScriptView Raw
1/* eslint-disable unicorn/no-process-exit */
2'use strict';
3let updateNotifier = require('.');
4
5const options = JSON.parse(process.argv[2]);
6
7updateNotifier = new updateNotifier.UpdateNotifier(options);
8
9(async () => {
10 // Exit process when offline
11 setTimeout(process.exit, 1000 * 30);
12
13 const update = await updateNotifier.fetchInfo();
14
15 // Only update the last update check time on success
16 updateNotifier.config.set('lastUpdateCheck', Date.now());
17
18 if (update.type && update.type !== 'latest') {
19 updateNotifier.config.set('update', update);
20 }
21
22 // Call process exit explicitly to terminate the child process,
23 // otherwise the child process will run forever, according to the Node.js docs
24 process.exit();
25})().catch(error => {
26 console.error(error);
27 process.exit(1);
28});