core/factories/step.factory.ts

core/factories/step.factory.ts is a file in Bane's Lab Build Scripts. 16 lines of code and 3 definitions.

import type { SiteMode, SiteStep, StepSpec } from "#types/site.types";
import { registerStep } from "#core/registries/step.registry";

const EVERY_MODE: readonly SiteMode[] = ["build", "serve"];

export const defineStep = function defineStep(spec: StepSpec): SiteStep {
    const step: SiteStep = {
        cache: spec.cache,
        gives: spec.gives ?? [spec.name],
        modes: spec.modes ?? EVERY_MODE,
        name: spec.name,
        needs: spec.needs ?? [],
        phase: spec.phase,
        run: spec.run,
    };
    registerStep(step);
    return step;
};