update-notifier.js
1.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
// # boot - update notifier
var _ = require('underscore')
var updateNotifier = require('update-notifier')
exports = module.exports = function(logger, settings) {
return function() {
// check for updates to all packages when not in production
if (settings.updateNotifier.enabled)
_.each(settings.pkg.dependencies, function(version, name) {
var notifier = updateNotifier({
packageName: name,
packageVersion: version,
optOut: settings.updateNotifier.dependencies[name] || false,
updateCheckInterval: settings.updateNotifier.updateCheckInterval | 1000 * 60 * 60, // hourly
updateCheckTimeout: settings.updateNotifier.updateCheckTimeout | 1000 * 20 // 20 seconds
})
if (_.isUndefined(notifier.update) || !_.isString(notifier.update.latest)) return
logger.warn(
'%s of %s released (current: %s), run `npm install -S %s@%s` to upgrade',
notifier.update.latest,
name,
version,
name,
notifier.update.latest
)
})
}
}
exports['@singleton'] = true
exports['@require'] = [ 'igloo/logger', 'igloo/settings' ]