resolveScenarioPath method

String resolveScenarioPath(
  1. String path
)

Override to resolve special scenario path values. Return a file system path, or throw if resolution fails. The default implementation checks the path directly and also searches candidates like scenarios/<name>.json.

Implementation

String resolveScenarioPath(String path) {
  final trimmed = path.trim();
  if (trimmed.isEmpty) {
    throw const io.FileSystemException('Scenario path is empty');
  }
  if (io.File(trimmed).existsSync()) return trimmed;

  final withJson = trimmed.endsWith('.json') ? trimmed : '$trimmed.json';
  final candidates = <String>[trimmed, withJson];
  candidates.add('scenarios/$trimmed');
  candidates.add('scenarios/$withJson');
  for (final candidate in candidates) {
    if (io.File(candidate).existsSync()) return candidate;
  }
  throw io.FileSystemException('Replay scenario file not found', path);
}