FileConfig.fromYaml constructor
FileConfig.fromYaml(
- dynamic entry
Implementation
factory FileConfig.fromYaml(dynamic entry) {
if (entry is String) {
return FileConfig(targetPath: entry.trim());
} else if (entry is Map) {
final target = entry['target'] as String? ?? entry['path'] as String?;
if (target == null || target.isEmpty) {
throw const FormatException(
'File entry must contain a "target" or "path" key.');
}
return FileConfig(
targetPath: target.trim(),
templatePath: entry['template'] as String?,
content: entry['content'] as String?,
);
}
throw FormatException('Invalid file entry format: $entry');
}