Skip to content
This repository has been archived by the owner on Aug 30, 2021. It is now read-only.

Commit

Permalink
adding chalk for formatting console messages instead of ANSI escape c…
Browse files Browse the repository at this point in the history
…odes
  • Loading branch information
lirantal committed Oct 24, 2014
1 parent a799a23 commit 22e330b
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
9 changes: 5 additions & 4 deletions config/init.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
/**
* Module dependencies.
*/
var glob = require('glob');
var glob = require('glob'),
chalk = require('chalk');

/**
* Module init function.
Expand All @@ -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');
});
Expand Down
7 changes: 4 additions & 3 deletions server.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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));
}
});

Expand Down

0 comments on commit 22e330b

Please sign in to comment.