Skip to content

Commit

Permalink
cli: update display color of all occurences of tessel.name. (#1228)
Browse files Browse the repository at this point in the history
Signed-off-by: Rick Waldron <waldron.rick@gmail.com>
  • Loading branch information
rwaldron committed Jun 6, 2017
1 parent 3a4280c commit d2f7f71
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 12 deletions.
22 changes: 11 additions & 11 deletions lib/controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ Tessel.list = function(opts) {
return controller.runHeuristics(opts, foundTessels)
.then(tessel => {
// Report that selected Tessel to the user
log.info('Will default to %s.', tessel.name);
log.info(`Will default to ${colors.magenta(tessel.name)}.`);
})
.catch(error => {
/* istanbul ignore else */
Expand Down Expand Up @@ -627,7 +627,7 @@ controller.renameTessel = function(options) {
})
.then(() => {
return controller.standardTesselCommand(options, (tessel) => {
log.info(`Renaming ${tessel.name} to ${options.newName}`);
log.info(`Renaming ${colors.magenta(tessel.name)} to ${colors.magenta(options.newName)}`);
return tessel.rename(options);
});
});
Expand All @@ -641,7 +641,7 @@ controller.printAvailableNetworks = function(options) {
// Ask Tessel what networks it finds in a scan
return tessel.findAvailableNetworks()
.then((networks) => {
log.info(`Found ${networks.length} network${networks.length !== 1 ? 's' : ''} visible to ${tessel.name}:`);
log.info(`Found ${networks.length} network${networks.length !== 1 ? 's' : ''} visible to ${colors.magenta(tessel.name)}:`);

// Print out networks
networks.forEach((network) => {
Expand Down Expand Up @@ -803,7 +803,7 @@ controller.getAccessPointInfo = function(options) {
log.info(`IP Address: ${ap.ip}`);
log.info(`State: ${(!Number(ap.disabled) ? 'Enabled' : 'Disabled')}`);
} else {
log.info(`${tessel.name} is not configured as an access point (run "t2 ap --help" to learn more)`);
log.info(`${colors.magenta(tessel.name)} is not configured as an access point (run "t2 ap --help" to learn more)`);
}
});
});
Expand Down Expand Up @@ -958,18 +958,18 @@ controller.updateWithRemoteBuilds = function(opts, tessel) {
// Check if the current build is the same or newer if this isn't a forced update
if (!opts.force && semver.gte(currentVersionInfo.version, verifiedVersion)) {
// If it's not, close the Tessel connection and print the error message
var message = tessel.name + ' is already on the latest firmware version (' + currentVersionInfo.version + '). You can force an update with "t2 update --force".';
var message = `${colors.magenta(tessel.name)} is already on the latest firmware version (${currentVersionInfo.version}). You can force an update with "t2 update --force".`;

log.warn(message);

return resolve();
} else {
if (!opts.force) {
// If it is a newer version, let's update...
log.info('New firmware version found...' + verifiedVersion);
log.info(`New firmware version found... ${verifiedVersion}`);
}

log.info('Updating ' + tessel.name + ' to latest version (' + verifiedVersion + ')...');
log.info(`Updating ${colors.magenta(tessel.name)} to latest version (${verifiedVersion})...`);

// Fetch the requested version
return controller.updateTesselWithVersion(opts, tessel, currentVersionInfo.version, build);
Expand All @@ -986,15 +986,15 @@ controller.updateTesselWithVersion = function(opts, tessel, currentVersion, buil

// Fetch the requested build
return updates.fetchBuild(build)
.then(function startUpdate(image) {
.then(image => {
// Update Tessel with it
return tessel.update(opts, image)
// Log that the update completed
.then(function logCompletion() {
.then(() => {
if (!opts.force) {
log.info('Updated', tessel.name, 'from ', currentVersion, ' to ', build.version);
log.info(`Updated ${colors.magenta(tessel.name)} from ${currentVersion} to ${build.version}`);
} else {
log.info('Force updated', tessel.name, 'to version', build.version);
log.info(`Force updated ${colors.magenta(tessel.name)} to version ${build.version}`);
}
});
});
Expand Down
2 changes: 1 addition & 1 deletion lib/tessel/deploy.js
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,7 @@ exportables.sendBundle = function(tessel, opts) {
}

// Log write
log.info('Writing project to %s on %s (%d kB)...', memtype, tessel.name, bundle.length / 1000);
log.info(`Writing project to ${memtype} on ${tessel.name} (${(bundle.length / 1000)} kB)...`);

// Calling receive to know when the process closes
tessel.receive(remoteProcess, (err) => {
Expand Down
1 change: 1 addition & 0 deletions test/.jshintrc
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
"cliPackageJson": true,
"commands": true,
"concat": true,
"colors": true,
"controller": true,
"copy": true,
"cp": true,
Expand Down
1 change: 1 addition & 0 deletions test/common/bootstrap.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ global.acorn = require('acorn');
global.async = require('async');
global.bindings = require('bindings');
global.charSpinner = require('char-spinner');
global.colors = require('colors');
global.concat = require('concat-stream');
global.fs = require('fs-extra');
global.fsTemp = require('fs-temp');
Expand Down
9 changes: 9 additions & 0 deletions test/unit/controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -1703,12 +1703,16 @@ exports['controller.printAvailableNetworks'] = {

this.tessel.name = 'robocop';

colors.enabled = false;

done();
},

tearDown(done) {
this.tessel.mockClose();
this.sandbox.restore();

colors.enabled = true;
done();
},

Expand Down Expand Up @@ -2287,12 +2291,17 @@ exports['controller.renameTessel'] = {
return callback(this.tessel);
});

colors.enabled = false;

done();
},

tearDown(done) {
this.tessel.mockClose();
this.sandbox.restore();

colors.enabled = true;

done();
},

Expand Down

0 comments on commit d2f7f71

Please sign in to comment.