-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added Util class to help detect TTY properly. (#41)
- Loading branch information
1 parent
6da921a
commit c1c1916
Showing
1 changed file
with
23 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<?php | ||
namespace Consolidation\SiteProcess\Util; | ||
|
||
use Symfony\Component\Process\Process; | ||
|
||
/** | ||
* Wrapper for universal support of TTY-related functionality across versions of | ||
* Symfony Process. | ||
*/ | ||
class Tty | ||
{ | ||
/** | ||
* In Symfony Process 4+, this is simply a wrapper for Process::isTtySupported(). | ||
* In lower versions, it mimics the same functionality. | ||
*/ | ||
public static function isTtySupported() | ||
{ | ||
if (method_exists('\Symfony\Component\Process\Process', 'isTtySupported')) { | ||
return Process::isTtySupported(); | ||
} | ||
return (bool) @proc_open('echo 1 >/dev/null', array(array('file', '/dev/tty', 'r'), array('file', '/dev/tty', 'w'), array('file', '/dev/tty', 'w')), $pipes); | ||
} | ||
} |