source: node_modules/simple-update-notifier/src/index.ts

main
Last change on this file was 81bc7da, checked in by Klimentina Efremova <klimentina08642@…>, 3 months ago

Initial commit

  • Property mode set to 100644
File size: 984 bytes
RevLine 
[81bc7da]1import isNpmOrYarn from './isNpmOrYarn';
2import hasNewVersion from './hasNewVersion';
3import { IUpdate } from './types';
4import borderedText from './borderedText';
5
6const simpleUpdateNotifier = async (args: IUpdate) => {
7 if (
8 !args.alwaysRun &&
9 (!process.stdout.isTTY || (isNpmOrYarn && !args.shouldNotifyInNpmScript))
10 ) {
11 if (args.debug) {
12 console.error('Opting out of running simpleUpdateNotifier()');
13 }
14 return;
15 }
16
17 try {
18 const latestVersion = await hasNewVersion(args);
19 if (latestVersion) {
20 console.error(
21 borderedText(`New version of ${args.pkg.name} available!
22Current Version: ${args.pkg.version}
23Latest Version: ${latestVersion}`)
24 );
25 }
26 } catch (err) {
27 // Catch any network errors or cache writing errors so module doesn't cause a crash
28 if (args.debug && err instanceof Error) {
29 console.error('Unexpected error in simpleUpdateNotifier():', err);
30 }
31 }
32};
33
34export default simpleUpdateNotifier;
Note: See TracBrowser for help on using the repository browser.