manuallyUpsertBrickFile method
Create or write to file.
Implementation
Future<File> manuallyUpsertBrickFile(String path, String contents) async {
final dirName = path.split('/').first;
if (!dirName.contains('.dart')) {
final dir = Directory(p.join('lib', 'brick', dirName));
final dirExists = await dir.exists();
if (!dirExists) {
await dir.create();
}
}
final newFile = File(p.join('lib', 'brick', path));
final fileExists = await newFile.exists();
if (!fileExists) {
await newFile.create();
}
final writtenFile = await newFile.writeAsString(contents);
return writtenFile;
}