@@ -71,23 +71,25 @@ const killExecaProcess = async (execaProcess) => {
71
71
*
72
72
* @param {Object } ctx
73
73
* @param {execa.ExecaChildProcess<string> } execaChildProcess
74
- * @returns {() => void } Function that clears the interval that
74
+ * @returns {() => Promise< void> } Function that clears the interval that
75
75
* checks the context.
76
76
*/
77
77
const interruptExecutionOnError = ( ctx , execaChildProcess ) => {
78
- let loopIntervalId
78
+ let intervalId , killPromise
79
79
80
80
const loop = async ( ) => {
81
81
if ( ctx . errors . size > 0 ) {
82
- clearInterval ( loopIntervalId )
83
- await killExecaProcess ( execaChildProcess )
82
+ clearInterval ( intervalId )
83
+ killPromise = killExecaProcess ( execaChildProcess )
84
+ await killPromise
84
85
}
85
86
}
86
87
87
- loopIntervalId = setInterval ( loop , ERROR_CHECK_INTERVAL )
88
+ intervalId = setInterval ( loop , ERROR_CHECK_INTERVAL )
88
89
89
- return ( ) => {
90
- clearInterval ( loopIntervalId )
90
+ return async ( ) => {
91
+ clearInterval ( intervalId )
92
+ await killPromise
91
93
}
92
94
}
93
95
@@ -155,7 +157,7 @@ export const resolveTaskFn = ({
155
157
156
158
const quitInterruptCheck = interruptExecutionOnError ( ctx , execaChildProcess )
157
159
const result = await execaChildProcess
158
- quitInterruptCheck ( )
160
+ await quitInterruptCheck ( )
159
161
160
162
if ( result . failed || result . killed || result . signal != null ) {
161
163
throw makeErr ( command , result , ctx )
0 commit comments