Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat: notify users whenever an update available #129

Merged
merged 3 commits into from
Jun 6, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions cli/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,25 @@ program.description('Start Jest Preview server.').action(() => {
});

program.parse(process.argv);

// Checks for available update and notify user
const updateNotifier = require('update-notifier');
const chalk = require('chalk');

const notifier = updateNotifier({
pkg: require('../package.json'),
updateCheckInterval: 0, // How often to check for updates
shouldNotifyInNpmScript: true, // Allows notification to be shown when running as an npm script
distTag: 'latest', // Can be use to notify user about pre-relase version
});

notifier.notify({
defer: true, // Try not to annoy user by showing the notification after the process has exited
message: [
`${chalk.blue('{packageName}')} has an update available: ${chalk.gray(
'{currentVersion}',
)} → ${chalk.green('{latestVersion}')}`,
`Please run ${chalk.cyan('`{updateCommand}`')} to update.`,
].join('\n'),
});
// END checks for available update and notify user
Loading