WeareJH / m2-module-import

Import module for Magento 2 - provides commands, utilities and abstractions for building imports for Magento 2 projects
MIT License
19 stars 8 forks source link

Allow CLI output in redirected STDOUT #50

Closed jbrada closed 2 years ago

jbrada commented 2 years ago

The module uses the posix_isatty(STDOUT) method (in non development mode) to detect whether someone ran a command from the CLI or not.

It may happen (and it is my use case) that I want to keep the command's output but need to redirect it somewhere else.

For example: bin/magento jh-import:run import-name > output.txt Or use a third-party tool - like Rundeck or GoCD

In this case, the output is empty.

My pull-request changes the CLI detection method to PHP_SAPI=='cli' for reports and keeps the progress bar only for unredirected STDOUT.

bartoszkubicki commented 2 years ago

It is such a nice improvement @jbrada! Thank you!