run method

  1. @override
Future<int> run(
  1. List<String> filePaths, {
  2. required void print(
    1. String?
    ),
  3. required void completeTask(
    1. HookTask,
    2. int
    ),
  4. required void startTask(
    1. HookTask
    ),
  5. required String? workingDirectory,
})
override

Runs the task with the given file paths.

filePaths is the list of file paths to process. print is a function to print messages. completeTask is a function to mark the task as complete. startTask is a function to mark the task as started.

Returns a FutureOr

Implementation

@override
Future<int> run(
  List<String> filePaths, {
  required void Function(String?) print,
  required void Function(HookTask, int) completeTask,
  required void Function(HookTask) startTask,
  required String? workingDirectory,
}) async {
  startTask(this);
  final paths = switch (workingDirectory) {
    final String cwd => [
      for (final path in filePaths)
        if (fs.path.isWithin(cwd, path))
          fs.path.relative(path, from: cwd)
        else
          path,
    ],
    null => filePaths.toList(),
  };

  final result = await _run(paths);

  completeTask(this, result);

  return result;
}