diff --git a/lib/platform/process.dart b/lib/platform/process.dart index 5fb8c95..6dbfa85 100644 --- a/lib/platform/process.dart +++ b/lib/platform/process.dart @@ -226,6 +226,8 @@ class ProcessExecutor { static Future run(StringBuffer shell, {String? workspace, bool printStdout = true, + bool printStderr = true, + Converter, String>? decoder, LogHandler? logHandler}) async { var c = Completer(); workspace = workspace ?? Directory.systemTemp.path; @@ -248,15 +250,21 @@ class ProcessExecutor { file.writeAsStringSync(shell.toString()); try { var shellExe = Platform.isMacOS ? 'zsh' : 'bash'; - await Process.run(shellExe, [file.path], workingDirectory: workspace) - .then((ProcessResult result) { - processResult = result; - }); + processResult = await Process.run(shellExe, [file.path], + workingDirectory: workspace); if (printStdout) { logHandler ?? ( // ignore: prefer_interpolation_to_compose_strings - '[ProcessExecutor] Exit Code: ${processResult!.exitCode}\nResult: ${processResult!.stdout}\nError: ${processResult!.stderr}', + '[ProcessExecutor] Result: ${processResult.stdout}', + LogType.verbose + ); + } + if (printStderr) { + logHandler ?? + ( + // ignore: prefer_interpolation_to_compose_strings + '[ProcessExecutor] Exit Code: ${processResult.exitCode}\nError: ${processResult.stderr}', LogType.verbose ); } @@ -269,10 +277,8 @@ class ProcessExecutor { } else if (Platform.isWindows) { file.createSync(); file.writeAsStringSync(shell.toString()); - await Process.run('cmd', ['/C', file.path], workingDirectory: workspace) - .then((ProcessResult result) { - processResult = result; - }); + processResult = await Process.run('cmd', ['/C', file.path], + workingDirectory: workspace); if (printStdout) { // print( // // ignore: prefer_interpolation_to_compose_strings