Skip to content

Commit

Permalink
Conditionally run update-notifier only if a non-root command has been…
Browse files Browse the repository at this point in the history
… run
  • Loading branch information
johnnyman727 committed May 14, 2016
1 parent 24fdd7d commit 3bd4ed2
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 8 deletions.
27 changes: 19 additions & 8 deletions bin/tessel-2.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
// Third Party Dependencies
var parser = require('nomnom').script('t2');
const updateNotifier = require('update-notifier');
const isRoot = require('is-root');

// Internal
var controller = require('../lib/controller');
Expand All @@ -20,14 +21,24 @@ const CLI_ENTRYPOINT = 'cli.entrypoint';
// Check for updates
const pkg = require('../package.json');

try {
updateNotifier({
pkg
}).notify();
} catch (err) {
CrashReporter.submit(err.stack, {
silent: true
});
/*
* If a command has been run with root,
* do not try to read the update-notifier config file.
* It will change the read permissions of the file and fail
* for all subsequent command line calls.
* Can be removed once https://github.com/npm/write-file-atomic/issues/11
* has been resolved.
*/
if (!isRoot()) {
try {
updateNotifier({
pkg
}).notify();
} catch (err) {
CrashReporter.submit(err.stack, {
silent: true
});
}
}

function makeCommand(commandName) {
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
"fstream-ignore": "1.0.2",
"glob": "^5.0.15",
"inquirer": "^0.8.5",
"is-root": "^1.0.0",
"mdns-js": "^0.4.0",
"minimatch": "^3.0.0",
"node-rsa": "^0.2.26",
Expand Down

0 comments on commit 3bd4ed2

Please sign in to comment.