public function isInteractive()

in src/Terminal.hack [76:105]


  public function isInteractive(): bool {
    // Explicit override
    $noninteractive = \getenv('NONINTERACTIVE');
    if ($noninteractive !== false) {
      if ($noninteractive === '1' || $noninteractive === 'true') {
        return false;
      }
      if ($noninteractive === '0' || $noninteractive === 'false') {
        return true;
      }
      /* HHAST_IGNORE_ERROR[DontUseAsioJoin] */
      \HH\Asio\join($this->stderr->writeAllAsync(
        "NONINTERACTIVE env var must be 0/1/yes/no/true/false, or unset.\n",
      ));
    }

    // Detects TravisCI and CircleCI; Travis gives you a TTY for STDIN
    $ci = \getenv('CI');
    if ($ci === '1' || $ci === 'true') {
      return false;
    }

    // Generic
    if (\posix_isatty(\STDIN) && \posix_isatty(\STDOUT)) {
      return true;
    }

    // Fail-safe
    return false;
  }