PHP 8.2.30
Preview: hasNewVersion.ts Size: 1.12 KB
/home/byroehnu/easepaybiz.easetack.com/node_modules/simple-update-notifier/src/hasNewVersion.ts

import semver from 'semver';
import { createConfigDir, getLastUpdate, saveLastUpdate } from './cache';
import getDistVersion from './getDistVersion';
import { IUpdate } from './types';

const hasNewVersion = async ({
  pkg,
  updateCheckInterval = 1000 * 60 * 60 * 24,
  distTag = 'latest',
  alwaysRun,
  debug,
}: IUpdate) => {
  createConfigDir();
  const lastUpdateCheck = getLastUpdate(pkg.name);
  if (
    alwaysRun ||
    !lastUpdateCheck ||
    lastUpdateCheck < new Date().getTime() - updateCheckInterval
  ) {
    const latestVersion = await getDistVersion(pkg.name, distTag);
    saveLastUpdate(pkg.name);
    if (semver.gt(latestVersion, pkg.version)) {
      return latestVersion;
    } else if (debug) {
      console.error(
        `Latest version (${latestVersion}) not newer than current version (${pkg.version})`
      );
    }
  } else if (debug) {
    console.error(
      `Too recent to check for a new update. simpleUpdateNotifier() interval set to ${updateCheckInterval}ms but only ${
        new Date().getTime() - lastUpdateCheck
      }ms since last check.`
    );
  }

  return false;
};

export default hasNewVersion;

Directory Contents

Dirs: 0 × Files: 12

Name Size Perms Modified Actions
127 B lr--r--r-- 2026-03-14 01:49:11
Edit Download
371 B lrw-r--r-- 2026-03-05 00:19:58
Edit Download
527 B lrw-r--r-- 2026-03-05 00:19:59
Edit Download
1.03 KB lrw-r--r-- 2026-03-05 00:19:59
Edit Download
810 B lrw-r--r-- 2026-03-05 00:20:00
Edit Download
811 B lrw-r--r-- 2026-03-05 00:20:00
Edit Download
2.32 KB lrw-r--r-- 2026-03-05 00:20:01
Edit Download
1.12 KB lrw-r--r-- 2026-03-05 00:20:02
Edit Download
744 B lrw-r--r-- 2026-03-05 00:20:02
Edit Download
984 B lrw-r--r-- 2026-03-05 00:20:03
Edit Download
444 B lrw-r--r-- 2026-03-05 00:20:04
Edit Download
202 B lrw-r--r-- 2026-03-05 00:20:04
Edit Download

If ZipArchive is unavailable, a .tar will be created (no compression).