2.0.0 • Published 2 months ago

tiny-update-notifier v2.0.0

Weekly downloads
-
License
MIT
Repository
github
Last release
2 months ago

tiny-update-notifier 📬

npm npm bundle size License

Simple check for npm package updates.

A lightweight alternative for update-notifier with most of the essential features. Useful for CLI apps.

Install

npm i tiny-update-notifier

Usage

import updateNotifier from 'tiny-update-notifier';
import packageJson from './package.json' assert { type: 'json' };

try {
    const update = await updateNotifier({ pkg: packageJson });

    if (update) {
        console.log(`New version of ${update.name} available!`);
        console.log(`Update: ${update.current} → ${update.latest} (${update.type})`);
    }
} catch {
    console.log('Couldn\'t get the latest version.');
}

API

updateNotifier(options)

Check for updates for an npm module.\ Returns: Update | false

Update

Contains information about update version etc.\ Type: Object

For example:

{ name: 'test', current: '1.0.0', latest: '3.3.0', type: 'major' }
name

The name of an npm module.\ Type: String

current

Current version of an npm module.\ Type: String

latest

Latest version of an npm module.\ Type: String

type

Difference type between current and latest semver version.\ Type: String

Possible values:

  • 'major'
  • 'premajor'
  • 'minor'
  • 'preminor'
  • 'patch'
  • 'prepatch'
  • 'prerelease'

options

Type: Object\ Options for getting new update.

pkg

Type: object (required)

name

Name of npm module.\ Type: String (required)

version

Version of npm module.\ Type: String (required)

distTag

Which dist-tag to use to find the latest version.

Type: String\ Default: 'latest'

checkInterval

How often to check for updates.

Type: Number\ Default: 1000 * 60 * 60 * 24 (1 day)

cache

Whether to use cache. Setting this option to false will cause checkInterval to not function, thus checking for new update every run.

Type: Boolean\ Default: true

timeout

Maximum time in milliseconds to wait for the request to npm registry to complete.

Type: Number\ Default: 30000 (30 seconds)

License

MIT 💖

2.0.0

2 months ago

1.0.1

6 months ago

1.0.0

7 months ago