Skip to content

Commit bbc0bab

Browse files
authored
fix: Prevent a project being named test (#18)
1 parent 53a3e24 commit bbc0bab

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

lib/commands/create_command.dart

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ Future<void> createCommand(ArgResults command) async {
2424
'Choose a name for your project: ',
2525
desc: 'Note: this must be a valid dart identifier (no dashes). '
2626
'For example: my_game',
27+
validate: (it) => !it.contains('-') && it != 'test',
2728
);
2829

2930
final org = getString(
@@ -34,6 +35,7 @@ Future<void> createCommand(ArgResults command) async {
3435
desc: 'Note: this is a dot separated list of "packages", '
3536
'normally in reverse domain notation. '
3637
'For example: org.flame_engine.games',
38+
validate: (it) => !it.contains('-'),
3739
);
3840

3941
final versions = FlameVersionManager.singleton.versions;

lib/utils.dart

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ String getString(
1717
String message, {
1818
required bool isInteractive,
1919
String? desc,
20+
bool Function(String)? validate,
2021
}) {
2122
var value = results[name] as String?;
2223
if (!isInteractive) {
@@ -29,7 +30,7 @@ String getString(
2930
if (desc != null) {
3031
stdout.write(ansi.darkGray.wrap('\n$desc\u{1B}[1A\r'));
3132
}
32-
value = prompts.get(message, validate: (it) => !it.contains('-'));
33+
value = prompts.get(message, validate: validate);
3334
if (desc != null) {
3435
stdout.write('\r\u{1B}[K');
3536
}

0 commit comments

Comments
 (0)