export async function precommitTask()

in packages/web-scripts/src/Tasks/CommitTasks.ts [49:71]


export async function precommitTask(
  task: PrecommitTaskDesc,
): Promise<string[]> {
  const fns: Array<(task?: PrecommitTaskDesc) => Promise<string>> = [];
  if (task.typecheck) {
    fns.push(typeCheck);
  }

  const results = await Promise.all(
    fns.map(async fn => {
      dbg('Beginning %s task', fn.name);
      const stdout = await fn(task);
      dbg('Finished %s task', fn.name);
      return stdout;
    }),
  );

  // unfortunately, lint-staged cannot be parallelized alongside any other tasks because it takes over the output
  // completely, rendering the output unreadable if anything is run with it.
  results.push(await lintStaged(task));

  return results;
}