hasTaskInvocationChanged method

Future<bool> hasTaskInvocationChanged(
  1. String taskName, [
  2. List<String> args = const []
])

Check if the given task had been invoked with the same arguments before.

Only successful task invocations are normally cached, hence this method will normally return true when the previous invocation of Task failed.

Implementation

Future<bool> hasTaskInvocationChanged(String taskName,
    [List<String> args = const []]) async {
  final taskFile = _taskFile(taskName);
  if (await taskFile.exists()) {
    final taskArgs = await taskFile.readAsString();
    final isChanged = args.toString() != taskArgs;
    if (isChanged) {
      logger.fine(() => 'Task "$taskName" invocation changed '
          'because args were $taskArgs, but is now $args.');
    } else {
      logger.finest(() => 'Task "$taskName" invocation has not '
          'changed, args are $taskArgs');
    }
    return isChanged;
  } else {
    logger.fine(() => 'Task "$taskName" has not been executed yet');
    return true;
  }
}