よくnpmを使っていて下と似たような通知を受けることがあると思います。
npm/cli: a package manager for JavaScript
これがupdate-notifier
です。npmをはじめ、色々なcliツールで使われています。
yeoman/update-notifier: Update notifications for your CLI app
このツールは非常に手軽に導入できます。
const updateNotifier = require('update-notifier');
const pkg = require('./package.json');
updateNotifier({pkg}).notify();
これだけです。
デフォルトだと、更新の確認は実行時に行われ、かつインターバルが1日なので、頻繁に通知がくることはありません。
自分の場合は、cliのオプションのパーサにmeowを使うことが多いので、以下のように書くことが多いです。
const meow = require('meow')
const updateNotifier = require('update-notifier')
const cli = meow(
`
Usage
$ hello [name]
Examples
$ hello
`,
{
flags: {
name: {
type: 'boolean',
},
},
}
)
updateNotifier({ pkg: cli.pkg }).notify()
// ...