@@ -708,14 +708,14 @@ export interface ProcessReturnType {
708
708
}
709
709
710
710
export async function spawnChildProcess ( program : string , args : string [ ] = [ ] , continueOn ?: string , cancellationToken ?: vscode . CancellationToken ) : Promise < ProcessReturnType > {
711
- const programOutput : ProcessOutput = await spawnChildProcessImpl ( program , args , continueOn , cancellationToken ) ;
712
- const exitCode : number | NodeJS . Signals | undefined = programOutput . exitCode ;
713
711
// Do not use CppSettings to avoid circular require()
714
712
const settings : vscode . WorkspaceConfiguration = vscode . workspace . getConfiguration ( "C_Cpp" , null ) ;
715
713
const loggingLevel : string | undefined = settings . get < string > ( "loggingLevel" ) ;
716
714
if ( loggingLevel === "Information" || loggingLevel === "Debug" ) {
717
- getOutputChannelLogger ( ) . appendLine ( `$ ${ program } ${ args . join ( ' ' ) } \n ${ programOutput . stderr || programOutput . stdout } \n ` ) ;
715
+ getOutputChannelLogger ( ) . appendLine ( `$ ${ program } ${ args . join ( ' ' ) } ` ) ;
718
716
}
717
+ const programOutput : ProcessOutput = await spawnChildProcessImpl ( program , args , continueOn , cancellationToken ) ;
718
+ const exitCode : number | NodeJS . Signals | undefined = programOutput . exitCode ;
719
719
if ( programOutput . exitCode ) {
720
720
return { succeeded : false , exitCode, output : programOutput . stderr || programOutput . stdout || localize ( 'process.exited' , 'Process exited with code {0}' , exitCode ) } ;
721
721
} else {
@@ -738,6 +738,10 @@ interface ProcessOutput {
738
738
739
739
async function spawnChildProcessImpl ( program : string , args : string [ ] , continueOn ?: string , cancellationToken ?: vscode . CancellationToken ) : Promise < ProcessOutput > {
740
740
return new Promise ( async ( resolve , reject ) => {
741
+ // Do not use CppSettings to avoid circular require()
742
+ const settings : vscode . WorkspaceConfiguration = vscode . workspace . getConfiguration ( "C_Cpp" , null ) ;
743
+ const loggingLevel : string | undefined = settings . get < string > ( "loggingLevel" ) ;
744
+
741
745
let proc : child_process . ChildProcess ;
742
746
if ( await isExecutable ( program ) ) {
743
747
proc = child_process . spawn ( `.${ isWindows ( ) ? '\\' : '/' } ${ path . basename ( program ) } ` , args , { shell : true , cwd : path . dirname ( program ) } ) ;
@@ -761,7 +765,11 @@ async function spawnChildProcessImpl(program: string, args: string[], continueOn
761
765
let stderr : string = '' ;
762
766
if ( proc . stdout ) {
763
767
proc . stdout . on ( 'data' , data => {
764
- stdout += data . toString ( ) ;
768
+ const str : string = data . toString ( ) ;
769
+ if ( loggingLevel !== "None" ) {
770
+ getOutputChannelLogger ( ) . append ( str ) ;
771
+ }
772
+ stdout += str ;
765
773
if ( continueOn ) {
766
774
const continueOnReg : string = escapeStringForRegex ( continueOn ) ;
767
775
if ( stdout . search ( continueOnReg ) ) {
0 commit comments