createCleanTask function

Task createCleanTask({
  1. String name = 'clean',
  2. String description = '',
  3. required Iterable<Task> tasks,
  4. TaskPhase phase = TaskPhase.setup,
})

Create a "clean" task that removes all outputs of the given tasks.

Implementation

Task createCleanTask(
    {String name = 'clean',
    String description = '',
    required Iterable<Task> tasks,
    TaskPhase phase = TaskPhase.setup}) {
  final allOutputs = tasks
      .map((e) => e.runCondition)
      .whereType<FilesCondition>()
      .map((e) => e.outputs)
      .toList(growable: false);
  return Task((_) async => await ignoreExceptions(() => deleteOutputs(tasks)),
      runCondition: RunToDelete(MultiFileCollection(allOutputs)),
      name: name,
      phase: phase,
      description: description);
}