From 2f0026a24b0681a1f9e0d32eaa496db3ec564595 Mon Sep 17 00:00:00 2001 From: Stuart Morgan Date: Fri, 1 Dec 2023 13:30:28 -0500 Subject: [PATCH] [pigeon] Use dart:io output inheritance for tooling Applies the same change as https://github.com/flutter/packages/pull/5410 to the Pigeon tooling, avoiding the need to manually wire up output forwarding. Also adjusts some callsites in the tooling that were forwarding all output normally but then also logging all output on failure to only log all output on failure. --- packages/pigeon/tool/shared/generation.dart | 1 + packages/pigeon/tool/shared/process_utils.dart | 16 ++++------------ 2 files changed, 5 insertions(+), 12 deletions(-) diff --git a/packages/pigeon/tool/shared/generation.dart b/packages/pigeon/tool/shared/generation.dart index de03c3c9424..00ec45b8d31 100644 --- a/packages/pigeon/tool/shared/generation.dart +++ b/packages/pigeon/tool/shared/generation.dart @@ -246,5 +246,6 @@ Future formatAllFiles({required String repositoryRoot}) { '--packages=pigeon', ], workingDirectory: repositoryRoot, + streamOutput: false, logFailure: true); } diff --git a/packages/pigeon/tool/shared/process_utils.dart b/packages/pigeon/tool/shared/process_utils.dart index a6a904b945f..28c816f18b1 100644 --- a/packages/pigeon/tool/shared/process_utils.dart +++ b/packages/pigeon/tool/shared/process_utils.dart @@ -3,27 +3,19 @@ // found in the LICENSE file. import 'dart:async'; -import 'dart:io' show Process, stderr, stdout; - -Future _streamOutput(Future processFuture) async { - final Process process = await processFuture; - await Future.wait(>[ - stdout.addStream(process.stdout), - stderr.addStream(process.stderr), - ]); - return process; -} +import 'dart:io' show Process, ProcessStartMode, stderr, stdout; Future runProcess(String command, List arguments, {String? workingDirectory, bool streamOutput = true, bool logFailure = false}) async { - final Future future = Process.start( + final Process process = await Process.start( command, arguments, workingDirectory: workingDirectory, + mode: + streamOutput ? ProcessStartMode.inheritStdio : ProcessStartMode.normal, ); - final Process process = await (streamOutput ? _streamOutput(future) : future); final int exitCode = await process.exitCode; if (exitCode != 0 && logFailure) { // ignore: avoid_print