Enable color output for cmd

I could not get my casperjs statements painted on my cmd.exe (Windows 7, x64). I followed ansicon .

If I understand correctly, statements are automatically colored if ansicon casperjs is installed

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 
+5
source share
2 answers

The answer here: ANSI-Coloring console output with .NET

The CasperJS binary package comes with precompiled casperjs.exe for the x86 platform. Unfortunately, this leads to the mention in x64 versions of ansicon.

Solutions:

  • Use x86 version of ansicon.exe
  • 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.

+2
source

I think your problem is that casperjs checks if the ANSICON environment variable is set on Windows, and if it is not set, it does not try to smooth out the output. Unfortunately, when you install ansicon the way you did, it does not actually set this variable in the environment in the usual way. Instead, it uses a rough hack to install it in the environment of the initial cmd.exe window process, but only if this cmd process tries to get its value. Since nothing usually uses the ANSICON environment ANSICON , this means that it usually will not be visible to another process (for example, casperjs ) in this window.

If this is a problem, all you have to do is set the ANSICON variable before running casperjs :

 set ANSICON=%ANSICON% 

You can also make this a permanent part of the environment using setx ANSICON=foo .

+2
source

Source: https://habr.com/ru/post/1201246/


All Articles