From adb6939ca179d992ac8626a048584a671040025e Mon Sep 17 00:00:00 2001 From: Mohammad Hamdan Date: Fri, 15 Nov 2024 17:29:37 +0400 Subject: [PATCH] Check if the workspace is flutter & run flutter analyze instead of dart analyze --- packages/melos/lib/src/commands/analyze.dart | 5 +++- .../melos/test/commands/analyze_test.dart | 28 +++++++++++++++++++ 2 files changed, 32 insertions(+), 1 deletion(-) diff --git a/packages/melos/lib/src/commands/analyze.dart b/packages/melos/lib/src/commands/analyze.dart index b51634a7..2d6453e8 100644 --- a/packages/melos/lib/src/commands/analyze.dart +++ b/packages/melos/lib/src/commands/analyze.dart @@ -110,7 +110,10 @@ mixin _AnalyzeMixin on _Melos { }) { final options = _getOptionsArgs(fatalInfos, fatalWarnings, concurrency); return [ - workspace.sdkTool('dart'), + if (workspace.isFlutterWorkspace) + workspace.sdkTool('flutter') + else + workspace.sdkTool('dart'), 'analyze', options, ]; diff --git a/packages/melos/test/commands/analyze_test.dart b/packages/melos/test/commands/analyze_test.dart index c423cd71..9b7ae893 100644 --- a/packages/melos/test/commands/analyze_test.dart +++ b/packages/melos/test/commands/analyze_test.dart @@ -277,6 +277,34 @@ $ melos analyze expect(regex.hasMatch(logger.output.normalizeNewLines()), isTrue); }); + test('should run analysis with using flutter', () async { + final workspaceDir = await createTemporaryWorkspace(); + + await createProject( + workspaceDir, + PubSpec( + name: 'a', + dependencies: { + 'c': HostedReference(VersionConstraint.any), + 'flutter': const SdkReference('flutter'), + }, + ), + ); + + final config = await MelosWorkspaceConfig.fromWorkspaceRoot(workspaceDir); + + final melos = Melos( + logger: logger, + config: config, + ); + await melos.analyze(concurrency: 2); + + final regex = + RegExp(r'\$ melos analyze\s+└> flutter analyze --concurrency 2'); + + expect(regex.hasMatch(logger.output.normalizeNewLines()), isTrue); + }); + test('should run analysis with --concurrency 2 flag', () async { await melos.analyze(concurrency: 2);