parseEnvFile method
Parses an environment file into a Map.
Supports KEY=VALUE, export KEY=VALUE, single or double quoted
values, and inline # comments after an unquoted value. Malformed
lines are reported as warnings and skipped.
Implementation
Future<Map<String, String>> parseEnvFile(File envFile) async {
if (!envFile.existsSync()) {
return {};
}
try {
return parseEnvContent(await envFile.readAsString(),
sourceName: envFile.path);
} catch (e, s) {
throw BuildException(
'Failed to read environment file at "${envFile.path}"',
fix:
'Ensure the file is readable and properly formatted as KEY=VALUE pairs.',
originalStackTrace: s,
);
}
}