runOrFail function

Future<void> runOrFail(
  1. String executable,
  2. List<String> args, {
  3. String? workingDirectory,
  4. String? errorMessage,
  5. bool silent = false,
})

Runs a command and throws if it fails.

Implementation

Future<void> runOrFail(
  String executable,
  List<String> args, {
  String? workingDirectory,
  String? errorMessage,
  bool silent = false,
}) async {
  final code = await runCommand(
    executable,
    args,
    workingDirectory: workingDirectory,
    silent: silent,
  );

  if (code != 0) {
    Logger.error(
        errorMessage ?? '$executable ${args.join(' ')} failed (exit $code)');
    exit(code);
  }
}