execute method

dynamic execute(
  1. GrinderContext context, [
  2. TaskArgs? args
])

This method is invoked when the task is started. If a task was created with a function, that function will be invoked by this method.

Implementation

dynamic execute(GrinderContext context, [TaskArgs? args]) {
  var taskFunction = this.taskFunction;
  if (taskFunction == null) return null;

  if (taskFunction is TaskFunction) {
    return zonedContext.withValue(
        context, () => taskFunction(args ?? TaskArgs(name, [])));
  } else if (taskFunction is _OldTaskFunction) {
    context.log(
        "warning: task definitions no longer require an explicit 'GrinderContext' parameter");
    return zonedContext.withValue(context, () => taskFunction(context));
  } else {
    return zonedContext.withValue(
        context, taskFunction as dynamic Function());
  }
}