run method

Future<int> run(
  1. String executable,
  2. List<String> arguments,
  3. {int nameWidth}
)

Implementation

Future<int> run(
  String executable,
  List<String> arguments, {
  int nameWidth,
}) async {
  final packName = packPen.write(
    " ${name.padRight(nameWidth)} ",
  );

  final cmd = [executable, ...arguments].join(" ");
  final command = commandPen.write(
    " ${cmd.padRight(nameWidth)} ",
  );

  print("${multipack}${packName}");
  print("${multipack}${command}");

  final process = await Process.start(
    executable,
    arguments,
    workingDirectory: directory.path,
  );

  process.stdout.listen((data) => stdout.add(data));
  process.stderr.listen((data) => stderr.add(data));

  final exitCode = await process.exitCode;

  final status = exitCode == 0
      ? successPen.write(" success ".padRight(nameWidth + 2))
      : failurePen.write(" failure ${exitCode} ".padRight(nameWidth + 2));

  print("${multipack}${status}");

  print("");

  return exitCode;
}