public function __construct()

in src/builders/HHImporter.hack [25:82]


  public function __construct(string $root, IncludedRoots $included_roots) {
    $config_file = $root.'/hh_autoload.json';
    if (!\file_exists($config_file)) {
      $roots = Vec\filter(vec['src', 'lib'], $x ==> \is_dir($root.'/'.$x));
      $dev_roots = Vec\filter(
        vec['test', 'tests', 'examples', 'example'],
        $x ==> \is_dir($root.'/'.$x),
      );
      \file_put_contents(
        $config_file,
        \json_encode(
          shape(
            'roots' => $roots,
            'devRoots' => $dev_roots,
            'devFailureHandler' => HHClientFallbackHandler::class,
          ),
          \JSON_PRETTY_PRINT,
        ).
        "\n",
      );
      \fprintf(
        \STDERR,
        "An hh_autoload.json is required; a skeleton has been written to %s.\n".
        "If changes are needed, run vendor/bin/hh-autoload after editing.\n".
        "\n".
        "*** WARNING ***\n".
        "This project will not work correctly unless vendor/hh_autoload.php is required.\n".
        "*** WARNING ***\n".
        "\n",
        $config_file,
      );
    }
    $config = ConfigurationLoader::fromFile($config_file);
    $this->config = $config;

    switch ($included_roots) {
      case IncludedRoots::PROD_ONLY:
        $roots = $config['roots'];
        break;
      case IncludedRoots::DEV_AND_PROD:
        $roots = Vec\concat($config['roots'], $config['devRoots']);
        break;
    }

    foreach ($roots as $tree) {
      if ($tree[0] !== '/') {
        $tree = $root.'/'.$tree;
      }
      $this->builders[] = Scanner::fromTree($tree, $config['parser']);
    }

    foreach ($config['extraFiles'] as $file) {
      if ($file[0] !== '/') {
        $file = $root.'/'.$file;
      }
      $this->files[] = $file;
    }
  }