mirror of
https://github.com/balena-io/balena-cli.git
synced 2024-12-22 15:02:22 +00:00
5de0f66d7a
`update-notifier` persist its update check results in a file, which is then read when running again the application. If this file gets written when the application is being run as root, we get ugly EPERM issues.
28 lines
506 B
JavaScript
28 lines
506 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;
|
|
}
|
|
return notifier.notify();
|
|
};
|
|
|
|
}).call(this);
|