Skip to content

toYamlFile

toYamlFile(model: Model, path: string, options?: ToYamlOptions): void

Serialize a model to a YAML file.

Creates any intermediate directories that do not yet exist and writes the YAML output synchronously. This is a convenience wrapper around toYaml for the common “write to disk” use case.

Parameter Type Description

model

Model

The model to serialize.

path

string

Destination file path (absolute or relative to cwd).

options?

ToYamlOptions

Optional settings forwarded to toYaml.

void

toYamlFile(myWorkflow, ".github/workflows/ci.yml");
// With a custom header:
toYamlFile(myAction, "action.yml", {
header: "Generated by {tool} v{version}",
});