Skip to content

Runner APIs

Runner APIs can be used to execute and apply Creations on disk:

Each runner API takes in up to two arguments:

  1. The construct to be run
  2. An object with properties from the construct’s context as well as:
    • directory: string (default: '.'): The root directory to write files to
    • mode (optional): What runtime mode to run in
    • options (optional): The construct’s Options values
    • Any properties from System contexts (optional)

runBlock

Given a Block, executes a Creation output by running its produce().

See Producers > runBlock for the arguments runBlock allows.

For example, given a Block that creates a README.md, this would write that file to system:

import { runBlock } from "create";
import { blockReadme } from "./blockReadme.js";
await runBlock(blockReadme);

runPreset

Given a Preset, executes a Creation output by running each of its Blocks produce().

See Producers > produceBlock for the arguments runPreset allows.

For example, given a Preset containing the previous Block that creates a README.md, this would write that file to system:

import { runBlock } from "create";
import { presetWithReadme } from "./presetWithReadme.js";
await runPreset(presetWithReadme, {
options: {
// ...
},
});
Made with 💝 in Boston by Josh Goldberg.