parseProviderQueueEnv function
Parses the FA_PROVIDERS_QUEUE env value: a JSON array, or @path to
load a JSON file (readText is injected — this library never touches
IO). Whitespace tolerance, BOM stripping, and line/col in JSON errors
(UT-parse-env-happy, UT-parse-file-form, E9).
Implementation
ParsedProviderQueue parseProviderQueueEnv(
String raw, {
String source = 'FA_PROVIDERS_QUEUE',
String? Function(String path) readText = _unreadable,
}) {
final trimmed = raw.trim();
if (trimmed.startsWith('@')) {
final path = trimmed.substring(1).trim();
final text = readText(path);
if (text == null) {
throw ConfigException(
'$source: cannot read queue file "$path" (relative paths resolve '
'against the working directory)',
);
}
return parseProviderQueueJsonText(text, source: '$source @${_quote(path)}');
}
return parseProviderQueueJsonText(trimmed, source: source);
}