run method
Runs this command.
The return value is wrapped in a Future if necessary and returned by
CommandRunner.runCommand.
Implementation
@override
Future<void> run() async {
final year = now.year;
final args = ensureArgResults();
final specificFile = args['license'];
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('File is already updated.');
}
}