diff --git a/lib/src/commands/create/commands/create_subcommand.dart b/lib/src/commands/create/commands/create_subcommand.dart index 3d6037b0..f94125f0 100644 --- a/lib/src/commands/create/commands/create_subcommand.dart +++ b/lib/src/commands/create/commands/create_subcommand.dart @@ -121,24 +121,14 @@ abstract class CreateSubCommand extends Command { return Directory(directory); } - /// The project name that the user provided. - /// - /// Since the project name could be user provided as either: - /// 1. A valid package name - /// 2. '.', the current working directory (the project assumes the cwd's name) - /// this needs to exist to provide a fallback value for [outputDirectory] and - /// [projectName]. - String get _projectName { + /// Gets the project name. + String get projectName { final args = argResults.rest; - _validateProjectName(args); - return args.first; + final name = path.basename(args.first); + _validateProjectName([name]); + return name; } - /// Gets the project name. - String get projectName => _projectName == '.' - ? path.basename(Directory.current.path) - : _projectName; - /// Gets the description for the project. String get projectDescription => argResults['description'] as String? ?? ''; @@ -223,12 +213,7 @@ abstract class CreateSubCommand extends Command { await template.onGenerateComplete( logger, - Directory( - [ - target.dir.path, - if (_projectName != '.') projectName, - ].join(Platform.pathSeparator), - ), + Directory(path.join(target.dir.path, projectName)), ); return ExitCode.success.code;