Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Correct the documentation and output of the bootstrap command in patapata_core #4

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.');
}
Loading