Skip to content

Commit

Permalink
fix: create directories if they dont exist
Browse files Browse the repository at this point in the history
  • Loading branch information
S-ecki committed Dec 2, 2023
1 parent a4654af commit 7eb1ced
Showing 1 changed file with 7 additions and 3 deletions.
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

0 comments on commit 7eb1ced

Please sign in to comment.