Skip to content

Commit

Permalink
t2 install-drivers: minor logging changes. Silences non linux platfor…
Browse files Browse the repository at this point in the history
…ms (where unnecessary)

Signed-off-by: Rick Waldron <waldron.rick@gmail.com>
  • Loading branch information
rwaldron committed Jun 22, 2016
1 parent d700d68 commit a4b79f7
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 9 deletions.
9 changes: 3 additions & 6 deletions bin/tessel-2.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,10 +72,7 @@ controller.crashReporter = function(options) {


controller.installDrivers = function() {
drivers.install().then(
module.exports.closeSuccessfulCommand,
module.exports.closeFailedCommand
);
return drivers.install();
};

function makeCommand(commandName) {
Expand Down Expand Up @@ -122,9 +119,9 @@ function makeCommand(commandName) {
});
}

function callControllerWith(methodName, opts) {
function callControllerWith(methodName, options) {
log.spinner.start();
return controller[methodName](opts)
return controller[methodName](options)
.then(module.exports.closeSuccessfulCommand, module.exports.closeFailedCommand);
}

Expand Down
8 changes: 6 additions & 2 deletions bin/tessel-install-drivers.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,13 @@ var fs = require('fs');
// Internal
var log = require('../lib/log');

module.exports.install = function() {
module.exports.install = function(options) {
return new Promise(function(resolve, reject) {
if (process.platform === 'linux') {
// --loglevel may be at "error" for npm postinstall script.
// if it's relevant, set the loglevel to info
log.level('info');

var rules_name = '85-tessel.rules';
var dest = '/etc/udev/rules.d/' + rules_name;
var rules = fs.readFileSync(__dirname + '/../resources/' + rules_name);
Expand All @@ -21,7 +25,7 @@ module.exports.install = function() {
fs.writeFileSync(dest, rules);
} catch (e) {
if (e.code === 'EACCES') {
log.info(`Could not write to ${dest}`);
log.error(`Could not write to ${dest}`);
log.info('Run "sudo t2 install-drivers"');
return -1;
} else {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"main": "./index.js",
"scripts": {
"test": "grunt test",
"postinstall": "t2 install-drivers || true"
"postinstall": "t2 install-drivers --loglevel=error || true"
},
"bin": {
"t2": "./bin/tessel-2.js"
Expand Down

0 comments on commit a4b79f7

Please sign in to comment.