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 System contexts and:
    • rootDirectory: string (default: '.'): The root directory to write files to

runBlock

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

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().

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);