replaceWithinFile method
Replace contents of file
Implementation
Future<File?> replaceWithinFile(String path, Pattern from, String to) async {
final file = File(p.join('lib', 'brick', path));
final fileExists = await file.exists();
if (!fileExists) return null;
final contents = await file.readAsString();
final replacedContents = contents.replaceAll(from, to);
return await file.writeAsString(replacedContents);
}