Don't check for available updates when running as root

`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.
This commit is contained in:
Juan Cruz Viotti 2015-08-20 16:54:22 -04:00
parent fb28cc7d2f
commit 5de0f66d7a
3 changed files with 15 additions and 5 deletions

View File

@ -1,13 +1,17 @@
(function() {
var notifier, packageJSON, updateNotifier;
var isRoot, notifier, packageJSON, updateNotifier;
updateNotifier = require('update-notifier');
isRoot = require('is-root');
packageJSON = require('../../package.json');
notifier = updateNotifier({
pkg: packageJSON
});
if (!isRoot()) {
notifier = updateNotifier({
pkg: packageJSON
});
}
exports.hasAvailableUpdate = function() {
return notifier != null;

View File

@ -1,7 +1,12 @@
updateNotifier = require('update-notifier')
isRoot = require('is-root')
packageJSON = require('../../package.json')
notifier = updateNotifier(pkg: packageJSON)
# `update-notifier` creates files to make the next
# running time ask for updated, however this can lead
# to ugly EPERM issues if those files are created as root.
if not isRoot()
notifier = updateNotifier(pkg: packageJSON)
exports.hasAvailableUpdate = ->
return notifier?

View File

@ -44,6 +44,7 @@
"coffee-script": "^1.9.3",
"columnify": "^1.5.2",
"html-to-text": "^1.3.1",
"is-root": "^1.0.0",
"lodash": "^3.10.0",
"mkdirp": "~0.5.0",
"nplugm": "^3.0.0",