Skip to content

Instantly share code, notes, and snippets.

@Jonas-Sander
Created November 20, 2020 17:01
Show Gist options
  • Save Jonas-Sander/0a586af3e2bcb2957b686bc5cb673d34 to your computer and use it in GitHub Desktop.
Save Jonas-Sander/0a586af3e2bcb2957b686bc5cb673d34 to your computer and use it in GitHub Desktop.
Add dart language comment "// @Dart=2.10" to top of dart files.
// @dart = 2.10
import 'dart:io';
import 'package:glob/glob.dart';
Future<void> main() async {
final replacements =
Glob('**.dart').list().asyncMap((fileSystemEntity) async {
if (fileSystemEntity is File) {
final content = await fileSystemEntity.readAsString();
await fileSystemEntity.writeAsString('// @dart = 2.10\n$content');
}
});
await replacements.last;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment