runBash function
Implementation
Future<ProcessResult> runBash(
String executable,
List<String> arguments, {
String? workingDirectory,
Map<String, String>? environment,
bool includeParentEnvironment = true,
Encoding? stdoutEncoding = systemEncoding,
Encoding? stderrEncoding = systemEncoding,
bool printCall = false,
}) async {
_runAsyncProcessLogger.log(printCall ? Level.INFO : Level.FINE,
'$executable ${arguments.join(' ')}');
final result = await Process.run(
'bash',
['-c', '$executable ${arguments.join(' ')}'],
workingDirectory: workingDirectory,
environment: environment,
includeParentEnvironment: includeParentEnvironment,
// Needed to work on windows
runInShell: true,
stdoutEncoding: stdoutEncoding,
stderrEncoding: stderrEncoding,
);
final stdOut = result.stdout;
if (stdOut is String && stdOut.isNotEmpty) _runProcessLogger.finer(stdOut);
final stdErr = result.stderr;
if (stdErr is String && stdErr.isNotEmpty) _runProcessLogger.severe(stdErr);
if (result.exitCode != 0) throw Exception(result.stderr.toString());
return result;
}