HEX
Server: Apache/2.4.52 (Ubuntu)
System: Linux ip-10-0-8-47 6.8.0-1021-aws #23~22.04.1-Ubuntu SMP Tue Dec 10 16:31:58 UTC 2024 aarch64
User: ubuntu (1000)
PHP: 8.1.2-1ubuntu2.22
Disabled: NONE
Upload Files
File: /var/www/api.javaapp.co.uk/node_modules/simple-update-notifier/src/index.ts
import isNpmOrYarn from './isNpmOrYarn';
import hasNewVersion from './hasNewVersion';
import { IUpdate } from './types';
import borderedText from './borderedText';

const simpleUpdateNotifier = async (args: IUpdate) => {
  if (
    !args.alwaysRun &&
    (!process.stdout.isTTY || (isNpmOrYarn && !args.shouldNotifyInNpmScript))
  ) {
    if (args.debug) {
      console.error('Opting out of running simpleUpdateNotifier()');
    }
    return;
  }

  try {
    const latestVersion = await hasNewVersion(args);
    if (latestVersion) {
      console.error(
        borderedText(`New version of ${args.pkg.name} available!
Current Version: ${args.pkg.version}
Latest Version: ${latestVersion}`)
      );
    }
  } catch (err) {
    // Catch any network errors or cache writing errors so module doesn't cause a crash
    if (args.debug && err instanceof Error) {
      console.error('Unexpected error in simpleUpdateNotifier():', err);
    }
  }
};

export default simpleUpdateNotifier;