updateFile function
Future<void>
updateFile(
- String file,
- UpdateRule rule, {
- String operation = '',
- int expectedMatchCount = 0,
Implementation
Future<void> updateFile(String file, UpdateRule rule,
{String operation = '', int expectedMatchCount = 0}) async {
try {
final matches = await FileUpdater.updateFile(File(file), rule);
final matchCount = matches.length;
debug(
'$operation is updated on $file, total changes: $matchCount, lines: [${matches.join(',')}]');
if (expectedMatchCount != matchCount) {
error('$operation is not updated as expected, please repair the $file');
}
} on InvalidFormatException catch (e) {
error(
'the $operation value in the ${argResults[fileOption]} file is not valid! RegExp: ${e.message}, $file');
}
return Future.delayed(bufferDuration);
}