@@ -63,7 +63,7 @@ export class HooksService implements IHooksService {
63
63
return this . executeHooks ( afterHookName , traceMessage , hookArguments ) ;
64
64
}
65
65
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 > {
67
67
if ( this . $config . DISABLE_HOOKS || ! this . $options . hooks ) {
68
68
return ;
69
69
}
@@ -75,19 +75,22 @@ export class HooksService implements IHooksService {
75
75
this . initialize ( projectDir ) ;
76
76
77
77
this . $logger . trace ( traceMessage ) ;
78
-
78
+ const results : any [ ] = [ ] ;
79
79
try {
80
80
for ( const hooksDirectory of this . hooksDirectories ) {
81
- await this . executeHooksInDirectory ( hooksDirectory , hookName , hookArguments ) ;
81
+ results . push ( await this . executeHooksInDirectory ( hooksDirectory , hookName , hookArguments ) ) ;
82
82
}
83
83
} catch ( err ) {
84
84
this . $logger . trace ( "Failed during hook execution." ) ;
85
85
this . $errors . failWithoutHelp ( err . message || err ) ;
86
86
}
87
+
88
+ return _ . flatten ( results ) ;
87
89
}
88
90
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 [ ] > {
90
92
hookArguments = hookArguments || { } ;
93
+ const results : any [ ] = [ ] ;
91
94
const hooks = this . getHooksByName ( directoryPath , hookName ) ;
92
95
for ( let i = 0 ; i < hooks . length ; ++ i ) {
93
96
const hook = hooks [ i ] ;
@@ -129,7 +132,8 @@ export class HooksService implements IHooksService {
129
132
if ( maybePromise ) {
130
133
this . $logger . trace ( 'Hook promises to signal completion' ) ;
131
134
try {
132
- await maybePromise ;
135
+ const result = await maybePromise ;
136
+ results . push ( result ) ;
133
137
} catch ( err ) {
134
138
if ( err && _ . isBoolean ( err . stopExecution ) && err . errorAsWarning === true ) {
135
139
this . $logger . warn ( err . message || err ) ;
@@ -144,12 +148,16 @@ export class HooksService implements IHooksService {
144
148
this . $logger . trace ( "Executing %s hook at location %s with environment " , hookName , hook . fullPath , environment ) ;
145
149
146
150
const output = await this . $childProcess . spawnFromEvent ( command , [ hook . fullPath ] , "close" , environment , { throwError : false } ) ;
151
+ results . push ( output ) ;
152
+
147
153
if ( output . exitCode !== 0 ) {
148
154
throw new Error ( output . stdout + output . stderr ) ;
149
155
}
150
156
}
151
157
}
152
158
}
159
+
160
+ return results ;
153
161
}
154
162
155
163
private getHooksByName ( directoryPath : string , hookName : string ) : IHook [ ] {
0 commit comments