mirror of
https://github.com/flynx/colors.js.git
synced 2025-10-29 19:10:10 +00:00
Fix #119 - use util.inspect for logging objects
This commit is contained in:
parent
1f617ecdc5
commit
8b51cf67b5
@ -33,6 +33,7 @@ module['exports'] = colors;
|
||||
|
||||
colors.themes = {};
|
||||
|
||||
var util = require('util');
|
||||
var ansiStyles = colors.styles = require('./styles');
|
||||
var defineProps = Object.defineProperties;
|
||||
|
||||
@ -87,14 +88,11 @@ var styles = (function () {
|
||||
var proto = defineProps(function colors() {}, styles);
|
||||
|
||||
function applyStyle() {
|
||||
var args = arguments;
|
||||
var argsLen = args.length;
|
||||
var str = argsLen !== 0 && String(arguments[0]);
|
||||
if (argsLen > 1) {
|
||||
for (var a = 1; a < argsLen; a++) {
|
||||
str += ' ' + args[a];
|
||||
}
|
||||
}
|
||||
var args = Array.prototype.slice.call(arguments);
|
||||
|
||||
var str = args.map(function(arg) {
|
||||
return typeof arg === 'object' ? util.inspect(arg) : arg;
|
||||
}).join(' ');
|
||||
|
||||
if (!colors.enabled || !str) {
|
||||
return str;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user