runOrFail method Null safety

  1. @protected
Future<ProcessResult> runOrFail(
  1. Future<ProcessResult> run(
      ),
    1. {bool printStdOut = true}
    )

    Implementation

    @protected
    Future<ProcessResult> runOrFail(Future<ProcessResult> Function() run,
        {bool printStdOut = true}) async {
      final res = await run();
    
      final runOut = res.stdout?.toString();
      if (printStdOut && runOut != null && runOut.isNotEmpty) {
        printInfo(res.stdout.toString());
      }
    
      if (res.exitCode != 0) {
        throw RunException.withCode(res.exitCode, res.stderr.toString());
      }
    
      return res;
    }