@@ -494,7 +494,7 @@ public static string RenewAzureToken(string tenantId, string clientId, string ap
494
494
throw new KubeConfigException ( "Refresh not supported." ) ;
495
495
}
496
496
497
- public static Process CreateRunnableExternalProcess ( ExternalExecution config )
497
+ public static Process CreateRunnableExternalProcess ( ExternalExecution config , EventHandler < DataReceivedEventArgs > captureStdError = null )
498
498
{
499
499
if ( config == null )
500
500
{
@@ -535,7 +535,7 @@ public static Process CreateRunnableExternalProcess(ExternalExecution config)
535
535
}
536
536
537
537
process . StartInfo . RedirectStandardOutput = true ;
538
- process . StartInfo . RedirectStandardError = true ;
538
+ process . StartInfo . RedirectStandardError = captureStdError != null ;
539
539
process . StartInfo . UseShellExecute = false ;
540
540
process . StartInfo . CreateNoWindow = true ;
541
541
@@ -560,14 +560,15 @@ public static ExecCredentialResponse ExecuteExternalCommand(ExternalExecution co
560
560
throw new ArgumentNullException ( nameof ( config ) ) ;
561
561
}
562
562
563
- var process = CreateRunnableExternalProcess ( config ) ;
563
+ var captureStdError = ExecStdError ;
564
+ var process = CreateRunnableExternalProcess ( config , captureStdError ) ;
564
565
565
566
try
566
567
{
567
568
process . Start ( ) ;
568
- if ( ExecStdError != null )
569
+ if ( captureStdError != null )
569
570
{
570
- process . ErrorDataReceived += ( s , e ) => ExecStdError . Invoke ( s , e ) ;
571
+ process . ErrorDataReceived += captureStdError . Invoke ;
571
572
process . BeginErrorReadLine ( ) ;
572
573
}
573
574
}
0 commit comments