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
|
| Rev | Line | |
|---|
| [81bc7da] | 1 | import isNpmOrYarn from './isNpmOrYarn';
|
|---|
| 2 | import hasNewVersion from './hasNewVersion';
|
|---|
| 3 | import { IUpdate } from './types';
|
|---|
| 4 | import borderedText from './borderedText';
|
|---|
| 5 |
|
|---|
| 6 | const 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!
|
|---|
| 22 | Current Version: ${args.pkg.version}
|
|---|
| 23 | Latest 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 |
|
|---|
| 34 | export default simpleUpdateNotifier;
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.