From 67bf2dedf314cbcaba797bdd79987e8cf9127f9f Mon Sep 17 00:00:00 2001 From: Moritz Date: Thu, 24 Oct 2024 16:03:01 +0200 Subject: [PATCH] Change exception --- pkgs/firehose/lib/src/health/health.dart | 36 +++++++++++++++--------- 1 file changed, 22 insertions(+), 14 deletions(-) diff --git a/pkgs/firehose/lib/src/health/health.dart b/pkgs/firehose/lib/src/health/health.dart index 34fdec72..9e47e8ec 100644 --- a/pkgs/firehose/lib/src/health/health.dart +++ b/pkgs/firehose/lib/src/health/health.dart @@ -217,28 +217,36 @@ ${changeForPackage.entries.map((e) => '|${e.key.name}|${e.value.toMarkdownRow()} path.relative(package.directory.path, from: directory.path); var tempDirectory = Directory.systemTemp.createTempSync(); var reportPath = path.join(tempDirectory.path, 'leaks.json'); + var arguments = [ + ...['pub', 'global', 'run'], + 'dart_apitool:main', + 'extract', + ...['--input', relativePath], + ...['--output', reportPath], + '--set-exit-on-missing-export', + ]; var runApiTool = Process.runSync( 'dart', - [ - ...['pub', 'global', 'run'], - 'dart_apitool:main', - 'extract', - ...['--input', relativePath], - ...['--output', reportPath], - '--set-exit-on-missing-export', - ], + arguments, workingDirectory: directory.path, ); log(runApiTool.stderr as String); log(runApiTool.stdout as String); - var fullReportString = File(reportPath).readAsStringSync(); - var decoded = jsonDecode(fullReportString) as Map; - var leaks = decoded['missingEntryPoints'] as List; + if (runApiTool.exitCode == 0) { + var fullReportString = await File(reportPath).readAsString(); + var decoded = jsonDecode(fullReportString) as Map; + var leaks = decoded['missingEntryPoints'] as List; - log('Leaking symbols in API:\n$leaks'); - if (leaks.isNotEmpty) { - leaksForPackage[package] = leaks.cast(); + log('Leaking symbols in API:\n$leaks'); + if (leaks.isNotEmpty) { + leaksForPackage[package] = leaks.cast(); + } + } else { + throw ProcessException( + 'Api tool finished with exit code ${runApiTool.exitCode}', + arguments, + ); } } return HealthCheckResult(