fillTemplates method
Fills templates
map with <templateName, fileContent> pairs
Implementation
Future<void> fillTemplates() async {
final templateDirRaw = argResults![templatesDirOption] as String?;
final templateDir = templateDirRaw ?? await defaultTemplateDirectoryPath();
templatesDirectoryPath = p.canonicalize(templateDir);
final templatesDirectory = Directory(templatesDirectoryPath);
if (!templatesDirectory.existsSync()) {
throw NonExistentFolderException(templatesDirectoryPath);
}
await Future.wait(templateNames.map((templateName) =>
readTemplateFile(templateName)
.then((fileContent) => templates[templateName] = fileContent)))
.catchError(
// ignore: avoid_types_on_closure_parameters
(Object _) =>
throw GenerateTemplatesUnreachableException('FileSystemException'),
test: (e) => e is FileSystemException,
);
}