@@ -63,7 +63,7 @@ export class HooksService implements IHooksService {
6363 return this . executeHooks ( afterHookName , traceMessage , hookArguments ) ;
6464 }
6565
66- private async executeHooks ( hookName : string , traceMessage : string , hookArguments ?: IDictionary < any > ) : Promise < void > {
66+ private async executeHooks ( hookName : string , traceMessage : string , hookArguments ?: IDictionary < any > ) : Promise < any > {
6767 if ( this . $config . DISABLE_HOOKS || ! this . $options . hooks ) {
6868 return ;
6969 }
@@ -75,19 +75,22 @@ export class HooksService implements IHooksService {
7575 this . initialize ( projectDir ) ;
7676
7777 this . $logger . trace ( traceMessage ) ;
78-
78+ const results : any [ ] = [ ] ;
7979 try {
8080 for ( const hooksDirectory of this . hooksDirectories ) {
81- await this . executeHooksInDirectory ( hooksDirectory , hookName , hookArguments ) ;
81+ results . push ( await this . executeHooksInDirectory ( hooksDirectory , hookName , hookArguments ) ) ;
8282 }
8383 } catch ( err ) {
8484 this . $logger . trace ( "Failed during hook execution." ) ;
8585 this . $errors . failWithoutHelp ( err . message || err ) ;
8686 }
87+
88+ return _ . flatten ( results ) ;
8789 }
8890
89- private async executeHooksInDirectory ( directoryPath : string , hookName : string , hookArguments ?: IDictionary < any > ) : Promise < void > {
91+ private async executeHooksInDirectory ( directoryPath : string , hookName : string , hookArguments ?: IDictionary < any > ) : Promise < any [ ] > {
9092 hookArguments = hookArguments || { } ;
93+ const results : any [ ] = [ ] ;
9194 const hooks = this . getHooksByName ( directoryPath , hookName ) ;
9295 for ( let i = 0 ; i < hooks . length ; ++ i ) {
9396 const hook = hooks [ i ] ;
@@ -129,7 +132,8 @@ export class HooksService implements IHooksService {
129132 if ( maybePromise ) {
130133 this . $logger . trace ( 'Hook promises to signal completion' ) ;
131134 try {
132- await maybePromise ;
135+ const result = await maybePromise ;
136+ results . push ( result ) ;
133137 } catch ( err ) {
134138 if ( err && _ . isBoolean ( err . stopExecution ) && err . errorAsWarning === true ) {
135139 this . $logger . warn ( err . message || err ) ;
@@ -144,12 +148,16 @@ export class HooksService implements IHooksService {
144148 this . $logger . trace ( "Executing %s hook at location %s with environment " , hookName , hook . fullPath , environment ) ;
145149
146150 const output = await this . $childProcess . spawnFromEvent ( command , [ hook . fullPath ] , "close" , environment , { throwError : false } ) ;
151+ results . push ( output ) ;
152+
147153 if ( output . exitCode !== 0 ) {
148154 throw new Error ( output . stdout + output . stderr ) ;
149155 }
150156 }
151157 }
152158 }
159+
160+ return results ;
153161 }
154162
155163 private getHooksByName ( directoryPath : string , hookName : string ) : IHook [ ] {
0 commit comments