@@ -160,21 +160,12 @@ export interface IWaitForExitWithBufferOptions extends IWaitForExitOptions {
160160}
161161
162162/**
163- * The result of running a process to completion using {@link Executable.(waitForExitAsync:3)}.
163+ * The result of running a process to completion using {@link Executable.(waitForExitAsync:3)}. This
164+ * interface does not include stdout or stderr output because an {@link IWaitForExitOptions.encoding} was not specified.
164165 *
165166 * @public
166167 */
167- export interface IWaitForExitResult < T extends Buffer | string | never = never > {
168- /**
169- * The process stdout output, if encoding was specified.
170- */
171- stdout : T ;
172-
173- /**
174- * The process stderr output, if encoding was specified.
175- */
176- stderr : T ;
177-
168+ export interface IWaitForExitResultWithoutOutput {
178169 /**
179170 * The process exit code. If the process was terminated, this will be null.
180171 */
@@ -188,6 +179,25 @@ export interface IWaitForExitResult<T extends Buffer | string | never = never> {
188179 signal : string | null ;
189180}
190181
182+ /**
183+ * The result of running a process to completion using {@link Executable.(waitForExitAsync:1)},
184+ * or {@link Executable.(waitForExitAsync:2)}.
185+ *
186+ * @public
187+ */
188+ export interface IWaitForExitResult < T extends Buffer | string = never >
189+ extends IWaitForExitResultWithoutOutput {
190+ /**
191+ * The process stdout output, if encoding was specified.
192+ */
193+ stdout : T ;
194+
195+ /**
196+ * The process stderr output, if encoding was specified.
197+ */
198+ stderr : T ;
199+ }
200+
191201// Common environmental state used by Executable members
192202interface IExecutableContext {
193203 currentWorkingDirectory : string ;
@@ -554,12 +564,12 @@ export class Executable {
554564 public static async waitForExitAsync (
555565 childProcess : child_process . ChildProcess ,
556566 options ?: IWaitForExitOptions
557- ) : Promise < IWaitForExitResult < never > > ;
567+ ) : Promise < IWaitForExitResultWithoutOutput > ;
558568
559- public static async waitForExitAsync < T extends Buffer | string | never = never > (
569+ public static async waitForExitAsync < T extends Buffer | string > (
560570 childProcess : child_process . ChildProcess ,
561571 options : IWaitForExitOptions = { }
562- ) : Promise < IWaitForExitResult < T > > {
572+ ) : Promise < IWaitForExitResult < T > | IWaitForExitResultWithoutOutput > {
563573 const { throwOnNonZeroExitCode, throwOnSignal, encoding } = options ;
564574 if ( encoding && ( ! childProcess . stdout || ! childProcess . stderr ) ) {
565575 throw new Error (
@@ -611,22 +621,31 @@ export class Executable {
611621 }
612622 ) ;
613623
614- let stdout : T | undefined ;
615- let stderr : T | undefined ;
616- if ( encoding === 'buffer' ) {
617- stdout = Buffer . concat ( collectedStdout as Buffer [ ] ) as T ;
618- stderr = Buffer . concat ( collectedStderr as Buffer [ ] ) as T ;
619- } else if ( encoding !== undefined ) {
620- stdout = collectedStdout . join ( '' ) as T ;
621- stderr = collectedStderr . join ( '' ) as T ;
622- }
624+ let result : IWaitForExitResult < T > | IWaitForExitResultWithoutOutput ;
625+ if ( encoding ) {
626+ let stdout : T | undefined ;
627+ let stderr : T | undefined ;
628+
629+ if ( encoding === 'buffer' ) {
630+ stdout = Buffer . concat ( collectedStdout as Buffer [ ] ) as T ;
631+ stderr = Buffer . concat ( collectedStderr as Buffer [ ] ) as T ;
632+ } else if ( encoding !== undefined ) {
633+ stdout = collectedStdout . join ( '' ) as T ;
634+ stderr = collectedStderr . join ( '' ) as T ;
635+ }
623636
624- const result : IWaitForExitResult < T > = {
625- stdout : stdout as T ,
626- stderr : stderr as T ,
627- exitCode,
628- signal
629- } ;
637+ result = {
638+ stdout : stdout as T ,
639+ stderr : stderr as T ,
640+ exitCode,
641+ signal
642+ } ;
643+ } else {
644+ result = {
645+ exitCode,
646+ signal
647+ } ;
648+ }
630649
631650 return result ;
632651 }
0 commit comments