diff --git a/lib/platform/process.dart b/lib/platform/process.dart index 74899fc..78ff666 100644 --- a/lib/platform/process.dart +++ b/lib/platform/process.dart @@ -113,12 +113,15 @@ class ProcessData { class ProcessExecutor { static Future startExe(String exe, List args, {String? workspace, bool? printStdout, bool? printStderr}) async { - var c = Completer(); var arg = '$exe ${args.join(' ')}'; - var processData = ProcessData(printStdout ?? true, printStderr ?? true); + var printStdout_ = printStdout ?? true; + var printStderr_ = printStderr ?? true; + var processData = ProcessData(printStdout_, printStderr_); if (Platform.isMacOS || Platform.isWindows) { workspace = workspace ?? Directory.systemTemp.path; - print('Execute Shell: $arg'); + if(printStdout_) { + print('Execute Shell: $arg'); + } try { processData.processValue = await Process.start(exe, args, workingDirectory: workspace); @@ -128,8 +131,7 @@ class ProcessExecutor { } else { print('This platform not support process executor.'); } - c.complete(processData); - return c.future; + return dataFutrue(processData); } static Future start(StringBuffer shell, @@ -139,7 +141,9 @@ class ProcessExecutor { bool? printStderr}) async { var c = Completer(); try { - var processData = ProcessData(printStdout ?? true, printStderr ?? true); + var printStdout_ = printStdout ?? true; + var printStderr_ = printStderr ?? true; + var processData = ProcessData(printStdout_, printStderr_); if (decoder != null) { processData.decoder = decoder; } @@ -147,7 +151,9 @@ class ProcessExecutor { workspace = workspace ?? Directory.systemTemp.path; var file = File('$workspace/$tempFileName'); processData.file = file; - print('Execute Shell: ${file.path} \n ${shell.toString()}'); + if(printStdout_) { + print('Execute Shell: ${file.path} \n ${shell.toString()}'); + } if (await file.exists()) { await file.delete(); } @@ -164,7 +170,9 @@ class ProcessExecutor { workspace = workspace ?? Directory.systemTemp.path; var file = File('$workspace/$tempFileName'); processData.file = file; - print('Execute Shell: ${file.path} \n ${shell.toString()}'); + if(printStdout_) { + print('Execute Shell: ${file.path} \n ${shell.toString()}'); + } if (await file.exists()) { await file.delete(); } @@ -193,8 +201,10 @@ class ProcessExecutor { var c = Completer(); workspace = workspace ?? Directory.systemTemp.path; var file = File('$workspace/$tempFileName'); - print('---------------------------------------------------'); - print('Shell Path: ${file.path} \nExecute Shell: ${shell.toString()}'); + if(printStdout) { + print('---------------------------------------------------'); + print('Shell Path: ${file.path} \nExecute Shell: ${shell.toString()}'); + } ProcessResult? processResult; if (Platform.isMacOS || Platform.isLinux) { file.createSync();