Skip to content
Browse files

Moved from colors to ansi-color

  • Loading branch information...
1 parent 6f3d9b3 commit cf6c5f10bfe51066d053270b1f2989cfff351eca @davglass davglass committed Sep 18, 2012
Showing with 24 additions and 17 deletions.
  1. +3 −3 lib/help.js
  2. +14 −7 lib/log.js
  3. +5 −5 lib/module.js
  4. +1 −1 lib/walk.js
  5. +1 −1 package.json
View
6 lib/help.js
@@ -17,9 +17,9 @@ if (args.version) {
var json = JSON.parse(c);
latest = json.version;
if (version < latest) {
- console.log('!!!WARNING!!!'.red);
- console.log(('your version ' + version + ' is out of date, the latest available version is ' + latest).red);
- console.log('update with: npm -g install shifter'.blue);
+ console.log(log.color('!!!WARNING!!!', 'red'));
+ console.log(log.color('your version ' + version + ' is out of date, the latest available version is ' + latest, 'red'));
+ console.log(log.color('update with: npm -g install shifter', 'blue'));
process.exit(1);
}
});
View
21 lib/log.js
@@ -3,28 +3,35 @@ Copyright (c) 2012, Yahoo! Inc. All rights reserved.
Code licensed under the BSD License:
http://yuilibrary.com/license/
*/
-require('colors');
+var color = require('ansi-color').set;
-var prefix = 'shifter'.magenta;
+var prefix = color('shifter', 'magenta');
+
+exports.color = function (str, code) {
+ if (code === 'gray' || code === 'grey') {
+ code = 'white';
+ }
+ return color(str, code);
+};
exports.info = function (str) {
- console.log(prefix, '[info]'.white, str);
+ console.log(prefix, color('[info]', 'white'), str);
};
exports.log = function (str) {
- console.log(prefix, '[queu]'.cyan, str);
+ console.log(prefix, color('[queu]', 'cyan'), str);
};
exports.warn = function (str) {
- console.log(prefix, '[warn]'.yellow, str);
+ console.log(prefix, color('[warn]', 'yellow'), str);
};
exports.error = function (str) {
- console.log(prefix, '[error]'.red, str);
+ console.log(prefix, color('[error]', 'red'), str);
process.exit(1);
};
exports.err = function (str) {
- console.log(prefix, '[err]'.red, str);
+ console.log(prefix, color('[err]', 'red'), str);
};
View
10 lib/module.js
@@ -34,7 +34,7 @@ var Stack = require('./stack').Stack,
compressorConfig = {
callback: function (e) {
log.err('compression failed');
- console.log(' ' + String(e.message).trim() + (' // line ' + e.line + ', pos ' + e.col).grey);
+ console.log(' ' + String(e.message).trim() + log.color(' // line ' + e.line + ', pos ' + e.col, 'white'));
log.error('dropped the clutch, build failed');
},
config: {
@@ -85,9 +85,9 @@ var Stack = require('./stack').Stack,
lint.forEach(function (item) {
counter = counter + 1;
- console[fn](' #' + counter + ': ' + ('[' + item.type + ']').red + ' ' + item.message.yellow);
+ console[fn](' #' + counter + ': ' + log.color('[' + item.type + ']', 'red') + ' ' + log.color(item.message, 'yellow'));
if (item.evidence) {
- console[fn](' ' + String(item.evidence).trim() + (' // line ' + item.line + ', pos ' + item.col).grey);
+ console[fn](' ' + String(item.evidence).trim() + log.color(' // line ' + item.line + ', pos ' + item.col, 'white'));
}
});
if (lintFail) {
@@ -114,9 +114,9 @@ var Stack = require('./stack').Stack,
messages.forEach(function (item) {
if (item && item.reason) {
counter = counter + 1;
- console[fn](' #' + counter + ': ' + item.reason.yellow);
+ console[fn](' #' + counter + ': ' + log.color(item.reason, 'yellow'));
if (item.evidence) {
- console[fn](' ' + String(item.evidence).trim() + (' // line ' + item.line + ', pos ' + item.character).grey);
+ console[fn](' ' + String(item.evidence).trim() + log.color(' // line ' + item.line + ', pos ' + item.character, 'white'));
}
}
});
View
2 lib/walk.js
@@ -85,7 +85,7 @@ exports.run = function (options) {
stdio: ['ignore', 'ignore', process.stderr]
});
child.on('exit', stack.add(function (code) {
- process.stdout.write((code ? '!'.red : '.'.white));
+ process.stdout.write((code ? log.color('!', 'red') : log.color('.', 'white')));
if (code) {
errors.push(mod);
}
View
2 package.json
@@ -4,7 +4,7 @@
"author": "Dav Glass <davglass@gmail.com>",
"version": "0.0.31",
"dependencies": {
- "colors": "*",
+ "ansi-color": "*",
"gear": "~0.7.0",
"gear-lib": "~0.8.0",
"nopt": "*",

0 comments on commit cf6c5f1

Please sign in to comment.
Something went wrong with that request. Please try again.