From 22e330b407081b031a4d9a400bbe77be809ba963 Mon Sep 17 00:00:00 2001 From: Liran Tal Date: Sat, 25 Oct 2014 01:05:08 +0300 Subject: [PATCH 1/3] adding chalk for formatting console messages instead of ANSI escape codes --- config/init.js | 9 +++++---- server.js | 7 ++++--- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/config/init.js b/config/init.js index d5bd17cc..84321a4c 100644 --- a/config/init.js +++ b/config/init.js @@ -3,7 +3,8 @@ /** * Module dependencies. */ -var glob = require('glob'); +var glob = require('glob'), + chalk = require('chalk'); /** * Module init function. @@ -19,14 +20,14 @@ module.exports = function() { console.log(); if (!environmentFiles.length) { if (process.env.NODE_ENV) { - console.error('\x1b[31m', 'No configuration file found for "' + process.env.NODE_ENV + '" environment using development instead'); + console.error(chalk.red('No configuration file found for "' + process.env.NODE_ENV + '" environment using development instead')); } else { - console.error('\x1b[31m', 'NODE_ENV is not defined! Using default development environment'); + console.error(chalk.red('NODE_ENV is not defined! Using default development environment')); } process.env.NODE_ENV = 'development'; } else { - console.log('\x1b[7m', 'Application loaded using the "' + process.env.NODE_ENV + '" environment configuration'); + console.log(chalk.black.bgWhite('Application loaded using the "' + process.env.NODE_ENV + '" environment configuration')); } console.log('\x1b[0m'); }); diff --git a/server.js b/server.js index e13d20d7..98d108bb 100755 --- a/server.js +++ b/server.js @@ -4,7 +4,8 @@ */ var init = require('./config/init')(), config = require('./config/config'), - mongoose = require('mongoose'); + mongoose = require('mongoose'), + chalk = require('chalk'); /** * Main application entry file. @@ -14,8 +15,8 @@ var init = require('./config/init')(), // Bootstrap db connection var db = mongoose.connect(config.db, function(err) { if (err) { - console.error('\x1b[31m', 'Could not connect to MongoDB!'); - console.log(err); + console.error(chalk.red('Could not connect to MongoDB!')); + console.log(chalk.red(err)); } }); From 9b694dbbf3bbf4c0aa796087e49bf0538ffd69d0 Mon Sep 17 00:00:00 2001 From: Liran Tal Date: Sat, 25 Oct 2014 01:05:34 +0300 Subject: [PATCH 2/3] adding chalk to package.json, locking to 0.5 version as a known and compliant API --- package.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index e785acbc..1e6474d1 100755 --- a/package.json +++ b/package.json @@ -44,7 +44,8 @@ "grunt-cli": "~0.1.13", "glob": "~4.0.5", "async": "~0.9.0", - "nodemailer": "~1.3.0" + "nodemailer": "~1.3.0", + "chalk": "~0.5" }, "devDependencies": { "supertest": "~0.14.0", From 1ee5bc1f46afa5677a4845293bca77c94708526b Mon Sep 17 00:00:00 2001 From: Liran Tal Date: Sat, 25 Oct 2014 01:06:19 +0300 Subject: [PATCH 3/3] removing un-necessary console.log() calls --- config/init.js | 2 -- 1 file changed, 2 deletions(-) diff --git a/config/init.js b/config/init.js index 84321a4c..8481057a 100644 --- a/config/init.js +++ b/config/init.js @@ -17,7 +17,6 @@ module.exports = function() { glob('./config/env/' + process.env.NODE_ENV + '.js', { sync: true }, function(err, environmentFiles) { - console.log(); if (!environmentFiles.length) { if (process.env.NODE_ENV) { console.error(chalk.red('No configuration file found for "' + process.env.NODE_ENV + '" environment using development instead')); @@ -29,7 +28,6 @@ module.exports = function() { } else { console.log(chalk.black.bgWhite('Application loaded using the "' + process.env.NODE_ENV + '" environment configuration')); } - console.log('\x1b[0m'); }); /**