Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Enable colors output for cmd

I couldn't get my casperjs asserts colored on my cmd.exe (Windows 7, x64). I followed ansicon.

If I understood right, asserts are colored automatically if ansicon is installed casperjs

Windows users will get colorized output if ansicon is installed.

Any ideas?

UPDATE

var casper = require('casper').create(),
    utils = require('utils'),
    http = require('http'),
    fs = require('fs'),
    colorizer = require('colorizer').create('Colorizer');

var xpath = require('casper').selectXPath;

casper.start('http://google.com/').then(function(response) {
    casper.echo('This is supposed to be green', 'INFO');
});

casper.run();

CMD:

C:\Users\itsme\Desktop>casperjs test test.js
Test file: test.js
This is supposed to be green

C:\Users\itsme\Desktop>casperjs test test.js
like image 607
smarber Avatar asked Sep 30 '22 00:09

smarber


1 Answers

The answer is over here: ANSI-Coloring Console Output with .NET

The CasperJS binary package comes with a pre-compiled casperjs.exe that targets the x86 platform. Unfortunately, that has the effect you mention on x64 versions of ansicon.

Solutions:

  1. Use the x86 version of ansicon.exe
  2. Recompile casperjs.exe for the x64 platform, which is quick and painless:

    C:\>cd casperjs\src
    C:\casperjs\src>C:\Windows\Microsoft.NET\Framework64\v4.0.30319\csc.exe /platform:x64 casperjs.cs
    

Copy the resulting .exe to the bin directory and you're done.

like image 53
Tomalak Avatar answered Oct 30 '22 21:10

Tomalak