Skip to content

Commit 2483da2

Browse files
authored
[flutter_tools] Do not treat 'daemon' argument as daemon command in logger initialization (flutter#191442)
## Description `executable.dart` checked `args.contains('daemon')` and `args.contains(WidgetPreviewCommand.kWidgetPreview)` to configure the logger. When running commands where 'daemon' was supplied as an argument (such as `flutter create daemon`), this caused `NotifyingLogger` to be initialized instead of standard loggers, silencing command output. Use `commandName` from `findCommandName(args)` to accurately detect if the command is `daemon` or `widget-preview`. ## Related Issues Fixes flutter#75876 ## Tests - Added unit test to `packages/flutter_tools/test/general.shard/executable_test.dart` - Added integration test to `packages/flutter_tools/test/integration.shard/command_output_test.dart`
1 parent 53643c2 commit 2483da2

3 files changed

Lines changed: 22 additions & 2 deletions

File tree

‎packages/flutter_tools/lib/executable.dart‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,8 +94,8 @@ Future<void> main(List<String> args) async {
9494
(args.length == 1 && verbose);
9595
final bool muteCommandLogging = (help || doctor) && !veryVerbose;
9696
final bool verboseHelp = help && verbose;
97-
final bool daemon = args.contains('daemon');
98-
final bool widgetPreviews = args.contains(WidgetPreviewCommand.kWidgetPreview);
97+
final daemon = commandName == 'daemon';
98+
final widgetPreviews = commandName == WidgetPreviewCommand.kWidgetPreview;
9999
final bool runMachine = args.contains('--machine');
100100

101101
// Cache.flutterRoot must be set early because other features use it (e.g.

‎packages/flutter_tools/test/general.shard/executable_test.dart‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ void main() {
3838

3939
test('does not mistake an argument of the command for the command', () {
4040
expect(findCommandName(<String>['create', 'doctor']), 'create');
41+
expect(findCommandName(<String>['create', 'daemon']), 'create');
42+
expect(findCommandName(<String>['create', 'widget-preview']), 'create');
4143
expect(findCommandName(<String>['help', 'doctor']), 'help');
4244
});
4345

‎packages/flutter_tools/test/integration.shard/command_output_test.dart‎

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -276,4 +276,22 @@ void main() {
276276
expect(result, const ProcessResultMatcher());
277277
expect(result.stderr, isEmpty);
278278
});
279+
280+
// Regression test for https://github.com/flutter/flutter/issues/75876.
281+
testWithoutContext('flutter create daemon produces output', () async {
282+
final Directory directory = createResolvedTempDirectorySync('create_daemon_test.');
283+
284+
try {
285+
final ProcessResult result = await processManager.run(<String>[
286+
flutterBin,
287+
'create',
288+
'--no-pub',
289+
'daemon',
290+
], workingDirectory: directory.path);
291+
expect(result.exitCode, 0);
292+
expect(result.stdout, contains('Creating project daemon...'));
293+
} finally {
294+
tryToDelete(directory);
295+
}
296+
});
279297
}

0 commit comments

Comments
 (0)