paulodiovani
paulodiovani

Reputation: 1305

Keep color output when running scripts on composer

Composer allow running scripts, as said in defining scripts.

So, I'm trying to run some spec tests with it.

{
    "scripts": {
        "test": "./vendor/davedevelopment/dspec/bin/dspec"
    },
    "require-dev": {
        "esperance/esperance": "dev-master",
        "davedevelopment/dspec": "dev-master"
    }
}

It runs fine, but there is no color output, and for spec tests this difficults the reading.

How can I run the scripts but keep the original colored output?

Upvotes: 19

Views: 6172

Answers (3)

Justin Howard
Justin Howard

Reputation: 5643

The davedevelopment/dspec library uses the symfony/console component. Symfony/console uses the POSIX extension to determine whether to allow color output. If you want color to show up by default without passing the --ansi flag, you just need to install the POSIX extension.

Upvotes: 2

Marcelo
Marcelo

Reputation: 1772

Use the --ansi param.

"test": "./vendor/davedevelopment/dspec/bin/dspec --ansi"

Upvotes: 39

Marcelo
Marcelo

Reputation: 1772

I've just run phpunit via composer and the colors are there. Perhaps the dspec script has no color support or is disabled by default.

"scripts" : {
  "test" : "./vendor/bin/phpunit -c tests/phpunit.xml"
},

Upvotes: 1

Related Questions