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

feat: test file generator #11

Merged
merged 7 commits into from
Dec 2, 2023
Merged
Changes from 1 commit
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
Prev Previous commit
Next Next commit
fix: create directories if they dont exist
  • Loading branch information
S-ecki committed Dec 2, 2023
commit 7eb1ced72f44e666744c23c56333274c1f5ab1cd
10 changes: 7 additions & 3 deletions day_generator.dart
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,17 @@ void main(List<String?> args) async {
// Create lib file
final dayFileName = 'day$dayNumber.dart';
unawaited(
File('solutions/$dayFileName').writeAsString(dayTemplate(dayNumber)),
File('solutions/$dayFileName')
.create(recursive: true)
.then((file) => file.writeAsString(_dayTemplate(dayNumber!))),
);

// Create test file
final testFileName = 'day${dayNumber}_test.dart';
unawaited(
File('test/$testFileName').writeAsString(_testTemplate(dayNumber)),
File('test/$testFileName')
.create(recursive: true)
.then((file) => file.writeAsString(_testTemplate(dayNumber!))),
);

final exportFile = File('solutions/index.dart');
Expand Down Expand Up @@ -84,7 +88,7 @@ void main(List<String?> args) async {
print('All set, Good luck!');
}

String dayTemplate(String dayNumber) {
String _dayTemplate(String dayNumber) {
return '''
import '../utils/index.dart';

Expand Down