updateYearOnFile method
Implementation
Future<void> updateYearOnFile(String? specificFile) async {
final year = now.year;
final file = specificFile is String
? await _findLicenseFile(specificFile)
: await _findDefaultLicenseFiles();
final contents = await file.readAsString();
if (!_yearIsUpdated(contents)) {
await file
.writeAsString(contents.replaceFirst(_yearRegexp, year.toString()));
printer.printSuccess(
'Year on ${file.basename} file has been updated to $year',
);
} else {
printer.println('Year on ${file.basename} file is already updated.');
}
}