diff --git a/lib/controller.js b/lib/controller.js index 3be334df..c41590fd 100644 --- a/lib/controller.js +++ b/lib/controller.js @@ -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 */ @@ -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); }); }); @@ -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) => { @@ -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)`); } }); }); @@ -958,7 +958,7 @@ 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); @@ -966,10 +966,10 @@ controller.updateWithRemoteBuilds = function(opts, tessel) { } 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); @@ -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}`); } }); }); diff --git a/lib/tessel/deploy.js b/lib/tessel/deploy.js index 3c0bf4a8..806c9786 100644 --- a/lib/tessel/deploy.js +++ b/lib/tessel/deploy.js @@ -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) => { diff --git a/test/.jshintrc b/test/.jshintrc index e8ce8a90..e59afa7c 100644 --- a/test/.jshintrc +++ b/test/.jshintrc @@ -26,6 +26,7 @@ "cliPackageJson": true, "commands": true, "concat": true, + "colors": true, "controller": true, "copy": true, "cp": true, diff --git a/test/common/bootstrap.js b/test/common/bootstrap.js index 51431d25..d452f5df 100644 --- a/test/common/bootstrap.js +++ b/test/common/bootstrap.js @@ -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'); diff --git a/test/unit/controller.js b/test/unit/controller.js index 02da625c..d6043de3 100644 --- a/test/unit/controller.js +++ b/test/unit/controller.js @@ -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(); }, @@ -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(); },