From ec7743708014a12723662171e8c24d2ead7dc015 Mon Sep 17 00:00:00 2001 From: Juan Cruz Viotti Date: Tue, 6 Oct 2015 18:51:17 -0400 Subject: [PATCH] Print plugin warnings in red as other errors For the sake of consistency. --- build/errors.js | 6 ++++-- build/utils/patterns.js | 8 +++++++- build/utils/plugins.js | 6 ++++-- lib/errors.coffee | 3 ++- lib/utils/patterns.coffee | 4 ++++ lib/utils/plugins.coffee | 3 ++- 6 files changed, 23 insertions(+), 7 deletions(-) diff --git a/build/errors.js b/build/errors.js index 92706d87..aafb044f 100644 --- a/build/errors.js +++ b/build/errors.js @@ -1,10 +1,12 @@ (function() { - var chalk, errors; + var chalk, errors, patterns; chalk = require('chalk'); errors = require('resin-cli-errors'); + patterns = require('./utils/patterns'); + exports.handle = function(error) { var message; message = errors.interpret(error); @@ -14,7 +16,7 @@ if (process.env.DEBUG) { message = error.stack; } - console.error(chalk.red(message)); + patterns.printErrorMessage(message); return process.exit(error.exitCode || 1); }; diff --git a/build/utils/patterns.js b/build/utils/patterns.js index 678e410d..73736b83 100644 --- a/build/utils/patterns.js +++ b/build/utils/patterns.js @@ -1,5 +1,5 @@ (function() { - var Promise, _, form, helpers, resin, visuals; + var Promise, _, chalk, form, helpers, resin, visuals; _ = require('lodash'); @@ -11,6 +11,8 @@ resin = require('resin-sdk'); + chalk = require('chalk'); + helpers = require('./helpers'); exports.selectDeviceType = function() { @@ -113,4 +115,8 @@ }); }; + exports.printErrorMessage = function(message) { + return console.error(chalk.red(message)); + }; + }).call(this); diff --git a/build/utils/plugins.js b/build/utils/plugins.js index 97527614..349d05eb 100644 --- a/build/utils/plugins.js +++ b/build/utils/plugins.js @@ -1,5 +1,5 @@ (function() { - var _, capitano, nplugm; + var _, capitano, nplugm, patterns; nplugm = require('nplugm'); @@ -7,6 +7,8 @@ capitano = require('capitano'); + patterns = require('./patterns'); + exports.register = function(regex) { return nplugm.list(regex).map(function(plugin) { var command; @@ -16,7 +18,7 @@ } return _.each(command, capitano.command); })["catch"](function(error) { - return console.error(error.message); + return patterns.printErrorMessage(error.message); }); }; diff --git a/lib/errors.coffee b/lib/errors.coffee index 048dd518..df654429 100644 --- a/lib/errors.coffee +++ b/lib/errors.coffee @@ -1,5 +1,6 @@ chalk = require('chalk') errors = require('resin-cli-errors') +patterns = require('./utils/patterns') exports.handle = (error) -> message = errors.interpret(error) @@ -8,5 +9,5 @@ exports.handle = (error) -> if process.env.DEBUG message = error.stack - console.error(chalk.red(message)) + patterns.printErrorMessage(message) process.exit(error.exitCode or 1) diff --git a/lib/utils/patterns.coffee b/lib/utils/patterns.coffee index c18ba232..b4b22bca 100644 --- a/lib/utils/patterns.coffee +++ b/lib/utils/patterns.coffee @@ -3,6 +3,7 @@ Promise = require('bluebird') form = require('resin-cli-form') visuals = require('resin-cli-visuals') resin = require('resin-sdk') +chalk = require('chalk') helpers = require('./helpers') exports.selectDeviceType = -> @@ -80,3 +81,6 @@ exports.awaitDevice = (uuid) -> resin.models.device.getName(uuid).then (deviceName) -> console.info("Waiting for #{deviceName} to connect to resin...") poll().return(uuid) + +exports.printErrorMessage = (message) -> + console.error(chalk.red(message)) diff --git a/lib/utils/plugins.coffee b/lib/utils/plugins.coffee index d6f6c06f..587485dc 100644 --- a/lib/utils/plugins.coffee +++ b/lib/utils/plugins.coffee @@ -1,6 +1,7 @@ nplugm = require('nplugm') _ = require('lodash') capitano = require('capitano') +patterns = require('./patterns') exports.register = (regex) -> nplugm.list(regex).map (plugin) -> @@ -8,4 +9,4 @@ exports.register = (regex) -> return capitano.command(command) if not _.isArray(command) return _.each(command, capitano.command) .catch (error) -> - console.error(error.message) + patterns.printErrorMessage(error.message)