smarter Casper.echo()
Showing
2 changed files
with
12 additions
and
1 deletions
... | @@ -497,6 +497,17 @@ Casper.prototype.each = function each(array, fn) { | ... | @@ -497,6 +497,17 @@ Casper.prototype.each = function each(array, fn) { |
497 | */ | 497 | */ |
498 | Casper.prototype.echo = function echo(text, style, pad) { | 498 | Casper.prototype.echo = function echo(text, style, pad) { |
499 | "use strict"; | 499 | "use strict"; |
500 | if (!utils.isString(text)) { | ||
501 | try { | ||
502 | text = text.toString(); | ||
503 | } catch (e) { | ||
504 | try { | ||
505 | text = utils.serialize(text); | ||
506 | } catch (e) { | ||
507 | text = ''; | ||
508 | } | ||
509 | } | ||
510 | } | ||
500 | var message = style ? this.colorizer.colorize(text, style, pad) : text; | 511 | var message = style ? this.colorizer.colorize(text, style, pad) : text; |
501 | console.log(this.filter('echo.message', message) || message); | 512 | console.log(this.filter('echo.message', message) || message); |
502 | return this; | 513 | return this; | ... | ... |
-
Please register or sign in to post a comment