withHooks method

Future<int> withHooks(
  1. String target,
  2. Future<int> action(
    1. HookStack stack
    ), {
  3. String? hooksFrom,
  4. HookOrder order = HookOrder.standard,
})

Runs action for target between its hooks. Outside a project, runs action without hooks.

Implementation

Future<int> withHooks(
  String target,
  Future<int> Function(HookStack stack) action, {
  String? hooksFrom,
  HookOrder order = HookOrder.standard,
}) {
  final project = this.project;
  if (project == null) {
    return action(hookStack);
  }
  final lifecycle = HookLifecycle(
    scripts: project.scripts,
    rootPath: project.rootPath,
    stack: hookStack,
    console: console,
    runHook: (hook, stack) => runScript(hook, stack: stack),
  );
  return lifecycle.run(target, action, hooksFrom: hooksFrom, order: order);
}