readConfig static method

TimerRewriteConfig readConfig(
  1. String? testsDirPath
)

Implementation

static TimerRewriteConfig readConfig(String? testsDirPath) {
  if (testsDirPath == null) return const TimerRewriteConfig();
  final file = File(p.join(testsDirPath, 'config.yaml'));
  if (!file.existsSync()) return const TimerRewriteConfig();
  final dynamic config = loadYaml(file.readAsStringSync());
  if (config is! YamlMap) return const TimerRewriteConfig();
  final timers = config['timers'];
  if (timers is! YamlMap) return const TimerRewriteConfig();
  return TimerRewriteConfig(
    enabled: timers['enabled'] == true,
    maxStartAfterSeconds: _parseNonNegativeInt(
      timers['maxStartAfterSeconds'],
      fallback: 1,
    ),
    maxRepeatIntervalSeconds: _parseNonNegativeInt(
      timers['maxRepeatIntervalSeconds'],
      fallback: 1,
    ),
    maxNumberOfTimes: timers['maxNumberOfTimes'] == null
        ? null
        : _parseNonNegativeInt(timers['maxNumberOfTimes'], fallback: 0),
    maxNumberOfTimesByScreen: _parseScreenTimerCaps(
      timers['maxNumberOfTimesByScreen'],
    ),
  );
}