📅 You're Invited: Meet the Socket team at RSAC (April 28 – May 1).RSVP
Socket
Sign inDemoInstall
Socket

update-notifier

Package Overview
Dependencies
Maintainers
9
Versions
52
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

update-notifier

Update notifications for your CLI app

7.3.1
latest
Source
npm
Version published
Weekly downloads
6.2M
-4.21%
Maintainers
9
Weekly downloads
 
Created

What is update-notifier?

The update-notifier npm package is used to inform users when a newer version of a particular npm package is available. It is particularly useful for CLI tools to notify users to update to the latest version.

What are update-notifier's main functionalities?

Basic Usage

This feature allows you to set up a basic notifier that checks for updates to the package specified in the package.json file. If an update is available, it will notify the user.

const updateNotifier = require('update-notifier');
const pkg = require('./package.json');

const notifier = updateNotifier({ pkg });

if (notifier.update) {
  notifier.notify();
}

Custom Message

This feature allows you to customize the message that is displayed to the user when an update is available.

const updateNotifier = require('update-notifier');
const pkg = require('./package.json');

const notifier = updateNotifier({ pkg });

if (notifier.update) {
  notifier.notify({
    message: 'Update available: ' + notifier.update.latest + '. Run `npm install -g ' + pkg.name + '` to update.'
  });
}

Check Interval

This feature allows you to set the interval at which the update check is performed. In this example, the check is performed once every 24 hours.

const updateNotifier = require('update-notifier');
const pkg = require('./package.json');

const notifier = updateNotifier({ pkg, updateCheckInterval: 1000 * 60 * 60 * 24 }); // 1 day

if (notifier.update) {
  notifier.notify();
}

Other packages similar to update-notifier

Keywords

npm

FAQs

Package last updated on 09 Sep 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts