mirror of
https://github.com/balena-io/balena-cli.git
synced 2024-12-22 23:12:22 +00:00
1cfbd4197d
Current has the following problems: - Our custom message gets printed even if the notifier doesn't contain an update. - The notifier box is deferred, therefore it's printed at the end of the command. Since our custom message is printed at the beginning, it makes no sense at all.
33 lines
673 B
JavaScript
33 lines
673 B
JavaScript
(function() {
|
|
var isRoot, notifier, packageJSON, updateNotifier;
|
|
|
|
updateNotifier = require('update-notifier');
|
|
|
|
isRoot = require('is-root');
|
|
|
|
packageJSON = require('../../package.json');
|
|
|
|
if (!isRoot()) {
|
|
notifier = updateNotifier({
|
|
pkg: packageJSON
|
|
});
|
|
}
|
|
|
|
exports.hasAvailableUpdate = function() {
|
|
return notifier != null;
|
|
};
|
|
|
|
exports.notify = function() {
|
|
if (!exports.hasAvailableUpdate()) {
|
|
return;
|
|
}
|
|
notifier.notify({
|
|
defer: false
|
|
});
|
|
if (notifier.update != null) {
|
|
return console.log('Notice that you might need administrator privileges depending on your setup\n');
|
|
}
|
|
};
|
|
|
|
}).call(this);
|