Skip to content

Commit 89ded61

Browse files
committed
wip: use paths instead of names with backwards compatibility
1 parent cc786aa commit 89ded61

File tree

1 file changed

+6
-21
lines changed

1 file changed

+6
-21
lines changed

lib/src/commands/create/commands/create_subcommand.dart

Lines changed: 6 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -121,24 +121,14 @@ abstract class CreateSubCommand extends Command<int> {
121121
return Directory(directory);
122122
}
123123

124-
/// The project name that the user provided.
125-
///
126-
/// Since the project name could be user provided as either:
127-
/// 1. A valid package name
128-
/// 2. '.', the current working directory (the project assumes the cwd's name)
129-
/// this needs to exist to provide a fallback value for [outputDirectory] and
130-
/// [projectName].
131-
String get _projectName {
124+
/// Gets the project name.
125+
String get projectName {
132126
final args = argResults.rest;
133-
_validateProjectName(args);
134-
return args.first;
127+
final name = path.basename(args.first);
128+
_validateProjectName([name]);
129+
return name;
135130
}
136131

137-
/// Gets the project name.
138-
String get projectName => _projectName == '.'
139-
? path.basename(Directory.current.path)
140-
: _projectName;
141-
142132
/// Gets the description for the project.
143133
String get projectDescription => argResults['description'] as String? ?? '';
144134

@@ -223,12 +213,7 @@ abstract class CreateSubCommand extends Command<int> {
223213

224214
await template.onGenerateComplete(
225215
logger,
226-
Directory(
227-
[
228-
target.dir.path,
229-
if (_projectName != '.') projectName,
230-
].join(Platform.pathSeparator),
231-
),
216+
Directory(path.join(target.dir.path, projectName)),
232217
);
233218

234219
return ExitCode.success.code;

0 commit comments

Comments
 (0)