Fix the --empty flag to not try working with non-app templates (#141632)

## Description

This adds a check to make sure that the `--empty` flag isn't applied to non-app templates.

## Related Issues
 - Fixes https://github.com/flutter/flutter/issues/141592

## Tests
 - Added a test.
This commit is contained in:
Greg Spencer
2024-01-17 08:51:03 -08:00
committed by GitHub
parent 9bbff1bb73
commit 4e3be0bf8e
2 changed files with 33 additions and 4 deletions

View File

@@ -2038,6 +2038,26 @@ void main() {
isNot(contains('Getting Started')));
});
testUsingContext("can't create an empty non-application project", () async {
final String outputDir = globals.fs.path.join(tempDir.path, 'test_project');
final CreateCommand command = CreateCommand();
final CommandRunner<void> runner = createTestCommandRunner(command);
final List<String> args = <String>[
'create',
'--no-pub',
'--empty',
'--template=plugin',
outputDir,
];
await expectLater(
runner.run(args),
throwsToolExit(
message: 'The --empty flag is only supported for the app template.',
));
});
testUsingContext('can create a sample-based project', () async {
await _createAndAnalyzeProject(
projectDir,