cleanPreviousOutputs method
Clean previous output files
Implementation
Future<int> cleanPreviousOutputs() async {
final RegExp pattern = RegExp('${RegExp.escape(config.outputPrefix)}-\\d{3}\\.(txt|md|json)\$');
int count = 0;
await for (final FileSystemEntity entity in Directory(workingDir).list()) {
if (entity is File && pattern.hasMatch(p.basename(entity.path))) {
await entity.delete();
count++;
if (config.verbose) {
verbose('Deleted: ${p.basename(entity.path)}');
}
}
}
return count;
}