revaliConfig property

Future<RevaliYaml> get revaliConfig

Implementation

Future<RevaliYaml> get revaliConfig async {
  if (__revaliConfig case final revaliConfig?) {
    return revaliConfig;
  }

  final root = await this.root;

  final constructYamlFile = root.childFile('revali.yaml');

  RevaliYaml? revaliConfig;
  if (await constructYamlFile.exists()) {
    final yamlContent = await constructYamlFile.readAsString();
    final yaml = loadYaml(yamlContent) as YamlMap?;

    try {
      if (yaml != null) {
        revaliConfig =
            RevaliYaml.fromJson(Map<String, dynamic>.from(yaml.value));
      }
    } catch (_) {
      logger.err('Failed to parse revali.yaml, using default configuration.');
    }
  }

  return __revaliConfig = revaliConfig ?? const RevaliYaml.none();
}