DartDefine.fromFile constructor
DartDefine.fromFile(
- String path, {
- required FileSystem fs,
Implementation
factory DartDefine.fromFile(String path, {required FileSystem fs}) {
final file = fs.file(path);
if (!file.existsSync()) {
throw ArgumentError.value(
file.path,
'file',
'File does not exist',
);
}
final lines = file.readAsLinesSync();
final defined = <String, String>{};
for (final line in lines) {
if (line.trim().isEmpty) continue;
if (line.startsWith('#')) continue;
final (:key, :value) = _parseEntry(line);
defined[key] = value;
}
return DartDefine(defined: defined, files: [file.path]);
}