Reputation: 939
If I specify a script in my composer.json
file:
"scripts": {
"test": "@php phpunit -c phpunit.xml"
}
Composer will echo the command when it is executed:
$user> composer test
> @php @php phpunit -c phpunit.xml
PHPUnit 8.0.1 by Sebastian Bergmann and contributors.
...
Is there anyway to suppress the echo'd command in Composer's output?
EDIT:
I'd like the output to look like this:
$user> composer test
PHPUnit 8.0.1 by Sebastian Bergmann and contributors.
...
Upvotes: 8
Views: 848
Reputation: 11185
Is there anyway to suppress the echo'd command in Composer's output?
It doesn't actually echo the command to STDOUT; it echos it to STDERR.
So
composer test 2> /dev/null
should give you clean output - see https://www.gnu.org/software/bash/manual/html_node/Redirections.html
also, if you're parsing composers output using software (like php exec
) they are often only reading STDOUT, and not receive exactly what you see on the command line.
Upvotes: 1
Reputation: 196
You could selectively erase the output of the composer command directly:
composer test 2>&1 | grep -v '^> @php'
This will redirect the stderr in stdout and then remove all lines that starts with > @php
(the > @php phpunit -c phpunit.xml
line is outputted in stderr)
The final output should be:
$user> composer test 2>&1 | grep -v '^> @php'
PHPUnit 8.0.1 by Sebastian Bergmann and contributors.
...
Then you could put the command in a sh script to avoid typing it every time
#!/bin/sh
composer test 2>&1 | grep -v '^> @php'
Upvotes: 3
Reputation: 156
On command line it shouldn't be possible. You can instead save the output into a file:
"tests": [
"@php phpunit -c phpunit.xml 2>&1 | tee COMPOSER-LOG",
"@php -v 2>&1 | tee COMPOSER-LOG"
]
Upvotes: 2