update-notifier
's direct dependencies. Data on all dependencies, including transitive ones, is available via CSV download.Name | Version | Size | License | Type | Vulnerabilities |
---|---|---|---|---|---|
boxen | 7.1.1 | 6.76 kB | MIT | prod | |
chalk | 5.3.0 | 13.08 kB | MIT | prod | |
configstore | 6.0.0 | 3.33 kB | BSD-2-Clause | prod | |
import-lazy | 4.0.0 | 2.17 kB | MIT | prod | |
is-in-ci | 0.1.0 | 2.07 kB | MIT | prod | |
is-installed-globally | 0.4.0 | 1.71 kB | MIT | prod | |
is-npm | 6.0.0 | 1.99 kB | MIT | prod | |
latest-version | 7.0.0 | 2.01 kB | MIT | prod | 1 |
pupa | 3.1.0 | 2.86 kB | MIT | prod | |
semver-diff | 4.0.0 | 2.09 kB | MIT | prod | |
semver | 7.6.2 | 93.19 kB | ISC | prod | |
xdg-basedir | 5.1.0 | 2.56 kB | MIT | prod |
The npm package "update-notifier" informs users of your CLI (Command Line Interface) application about the availability of new updates in a non-intrusive manner. It periodically checks with npm for updates in the background and, when available, it persistently displays the update notification. This enables the package consumers to always have the latest version, thereby promoting a similar experience as in browser-based applications.
For a simple usage of update-notifier, install the npm package and then import it in your JavaScript file along with your package.json file. After importing, invoke the updateNotifier
method with package.json
as the argument. Lastly, call the notify
method to enable update notifications. Here's a simple usage in code form:
import updateNotifier from 'update-notifier';
import packageJson from './package.json' assert {type: 'json'};
updateNotifier({pkg: packageJson}).notify();
For a more comprehensive usage, you may use the additional features provided by update-notifier. For example, the updateNotifier
method returns an instance that can get the information about available updates. This information can be accessed via the update
property of the instance.
Additionally, with update-notifier, you can customize the update checking interval and create custom notification messages.
import updateNotifier from 'update-notifier';
import packageJson from './package.json' assert {type: 'json'};
const notifier = updateNotifier({pkg: packageJson, updateCheckInterval: 1000 * 60 * 60 * 24 * 7});
if (notifier.update) {
console.log(`Update available: ${notifier.update.latest}`);
}
The official documentation for the update-notifier npm package is included in its README file on its GitHub repository. The README not only provides a thorough guide on the installation, usage, and features of the package but also talks about the philosophy behind its creation. The URL for the repository and hence the documentation is here.