@@ -39,6 +39,8 @@ An optional \`boolean\`, defaulting to \`false\`. If \`true\`, when one of the p
3939export { ParallelSchema as schema }
4040
4141export default class Parallel extends Task < { task : typeof ParallelSchema } > {
42+ taskInstances : Task < any > [ ] = [ ]
43+
4244 async run ( context : TaskRunContext ) {
4345 const tasks = this . options . tasks . flatMap ( ( entry ) =>
4446 Object . entries ( entry ) . map ( ( [ task , options ] ) => ( { task, options, plugin : this . plugin } ) )
@@ -56,30 +58,23 @@ ${tasks
5658` )
5759
5860 // HACK:KB:20250619 loadTasks expects config to be mutable, in TaskRunContext it's readonly, just cast it idc
59- const taskInstances = (
61+ this . taskInstances = (
6062 await loadTasks ( this . logger , tasks , context . config as WritableDeep < ValidConfig > )
6163 ) . unwrap ( 'tasks are invalid!' )
6264
6365 if ( this . options . stopOnError ) {
6466 try {
65- await Promise . all ( taskInstances . map ( ( task ) => task . run ( context ) ) )
67+ await Promise . all ( this . taskInstances . map ( ( task ) => task . run ( context ) ) )
6668 } catch ( error ) {
67- await Promise . all (
68- taskInstances . map ( ( task ) =>
69- task . stop ( ) . catch ( ( error ) => {
70- this . logger . warn ( `error stopping ${ styles . task ( this . id ) } :
71- ${ error . message } ` )
72- } )
73- )
74- )
69+ this . stop ( )
7570
7671 throw error
7772 }
7873 } else {
7974 const errors : ErrorSummary [ ] = [ ]
8075
8176 await Promise . all (
82- taskInstances . map ( ( task ) =>
77+ this . taskInstances . map ( ( task ) =>
8378 task . run ( context ) . catch ( ( error : Error ) => {
8479 errors . push ( {
8580 task : task . id ,
@@ -94,4 +89,15 @@ ${tasks
9489 }
9590 }
9691 }
92+
93+ async stop ( ) {
94+ await Promise . all (
95+ this . taskInstances . map ( ( task ) =>
96+ task . stop ( ) . catch ( ( error ) => {
97+ this . logger . warn ( `error stopping ${ styles . task ( task . id ) } :
98+ ${ error . message } `)
99+ } )
100+ )
101+ )
102+ }
97103}
0 commit comments