mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2025-10-16 12:05:41 +00:00
49 lines
1.1 KiB
TypeScript
49 lines
1.1 KiB
TypeScript
import UpdateNotifier = require('update-notifier');
|
|
|
|
let notifier = UpdateNotifier();
|
|
|
|
if (notifier.update) {
|
|
notifier.notify();
|
|
}
|
|
|
|
console.log(notifier.update);
|
|
|
|
// Also exposed as a class
|
|
notifier = new UpdateNotifier.UpdateNotifier({
|
|
updateCheckInterval: 1000 * 60 * 60 * 24 * 7 // 1 week
|
|
});
|
|
|
|
if (notifier.update) {
|
|
notifier.notify(); // test no options
|
|
notifier.notify({}); // test empty object
|
|
|
|
// test all options
|
|
notifier.notify({
|
|
message: 'Update available: ' + notifier.update.latest,
|
|
defer: false,
|
|
isGlobal: true,
|
|
boxenOpts: {
|
|
padding: 1,
|
|
margin: 1,
|
|
align: 'center',
|
|
borderColor: 'yellow',
|
|
borderStyle: 'round'
|
|
}
|
|
});
|
|
}
|
|
|
|
// Using the callback option
|
|
notifier = new UpdateNotifier.UpdateNotifier({
|
|
callback: (err, update) => {
|
|
if (err) throw err;
|
|
if (update) {
|
|
console.log(
|
|
update.current,
|
|
update.latest,
|
|
update.name,
|
|
update.type
|
|
);
|
|
}
|
|
}
|
|
});
|