Skip to content

Commit

Permalink
[pigeon] Use dart:io output inheritance for tooling (#5536)
Browse files Browse the repository at this point in the history
Applies the same change as #5410 to the Pigeon tooling, avoiding the need to manually wire up output forwarding.

Also adjusts a call site in the tooling that was forwarding all output normally but then also logging all output on failure to only log all output on failure.
  • Loading branch information
stuartmorgan authored Dec 6, 2023
1 parent 9a55d4c commit 49a60b8
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 12 deletions.
1 change: 1 addition & 0 deletions packages/pigeon/tool/shared/generation.dart
Original file line number Diff line number Diff line change
Expand Up @@ -246,5 +246,6 @@ Future<int> formatAllFiles({required String repositoryRoot}) {
'--packages=pigeon',
],
workingDirectory: repositoryRoot,
streamOutput: false,
logFailure: true);
}
16 changes: 4 additions & 12 deletions packages/pigeon/tool/shared/process_utils.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,27 +3,19 @@
// found in the LICENSE file.

import 'dart:async';
import 'dart:io' show Process, stderr, stdout;

Future<Process> _streamOutput(Future<Process> processFuture) async {
final Process process = await processFuture;
await Future.wait(<Future<Object?>>[
stdout.addStream(process.stdout),
stderr.addStream(process.stderr),
]);
return process;
}
import 'dart:io' show Process, ProcessStartMode, stderr, stdout;

Future<int> runProcess(String command, List<String> arguments,
{String? workingDirectory,
bool streamOutput = true,
bool logFailure = false}) async {
final Future<Process> 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
Expand Down

0 comments on commit 49a60b8

Please sign in to comment.