Skip to content

Commit

Permalink
fix: patapata_core documentation, add widget_test.dart overwrite logic
Browse files Browse the repository at this point in the history
  • Loading branch information
toshiaki-satsuma committed Mar 29, 2024
1 parent a08140e commit ec35e2f
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 1 deletion.
2 changes: 1 addition & 1 deletion packages/patapata_core/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ To just get the standard Patapata experience and have an app up and running, exe
flutter create my_app
cd my_app
flutter pub add patapata_core
dart run patapata_core:bootstrap
dart run patapata_core:bootstrap -f
```

Note that this will change the minimum Android SDK version to 21 and the minimum iOS version to 12.0.
Expand Down
29 changes: 29 additions & 0 deletions packages/patapata_core/bin/bootstrap.dart
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,10 @@ void main(List<String> arguments) {
// Check if the l10n directory exists.
// And if not, create it.
_checkL10nFiles(tResults);

// Check if a widget_test.dart file exists.
// And if not, create it with a empty code.
_checkWidgetTestFile(tResults);
} catch (e) {
switch (e) {
case UsageException():
Expand Down Expand Up @@ -997,3 +1001,28 @@ errors:

stdout.writeln('Done.');
}

void _checkWidgetTestFile(ArgResults results) {
stdout.writeln('Checking widget_test.dart file...');

final tFile = File('test/widget_test.dart');
final tFileExists = tFile.existsSync();

if (results['force'] == true || !tFileExists) {
stdout.writeln('Creating widget_test.dart file...');

if (!tFileExists) {
tFile.createSync(recursive: true);
}

tFile.writeAsStringSync(DartFormatter().format('''
import 'package:flutter_test/flutter_test.dart';
void main() {
testWidgets('empty', (WidgetTester tester) async {});
}
'''));
}

stdout.writeln('Done.');
}

0 comments on commit ec35e2f

Please sign in to comment.