From 50215182ef60d8ed0f5d4e5bc1849edf752d1164 Mon Sep 17 00:00:00 2001 From: Toki Date: Wed, 25 Dec 2024 15:53:50 +0900 Subject: [PATCH] =?UTF-8?q?print=20stdout=20=EC=A0=95=EB=A6=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/platform/process.dart | 30 ++++++++++++++++++++---------- 1 file changed, 20 insertions(+), 10 deletions(-) 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();