runBinary function

Future<ProcessResult> runBinary(
  1. String binary,
  2. List<String> args,
  3. String workingDirectory
)

Run a binary with the given arguments in a working directory.

Returns an ItemResult-compatible result via the callback parameters. The binary name is resolved to its platform-specific form before execution.

On Windows, runs in a shell to support .exe resolution from PATH.

final result = await runBinary('testkit', ['--dump-definitions'], '.');
if (result.exitCode == 0) {
  print(result.stdout);
}

Implementation

Future<ProcessResult> runBinary(
  String binary,
  List<String> args,
  String workingDirectory,
) async {
  final resolved = resolveBinary(binary);
  return Process.run(
    resolved,
    args,
    workingDirectory: workingDirectory,
    runInShell: Platform.isWindows,
  );
}