runTemplateCLI
Given a Template, runs an interactive CLI to generate and apply its output.
runTemplateCLI
is typically placed in a template repository’s package bin
entry to allow npx
execution of the template.
A typical bin file will look something like:
#!/usr/bin/env nodeimport { runTemplateCLI } from "bingo";
import template from "./template.js";
process.exitCode = await runTemplateCLI(template);
runTemplateCLI
takes in up to two arguments:
- A template (required)
package.json
data to display in the CLI (optional)
It returns a Promise for a numeric status code.
Package Data
If the optional package data argument is not provided, then runTemplateCLI
will attempt to read from the nearest package.json
to the file that is calling it.
You can alternately provide data yourself. You must provide at least:
name
(string
)version
(string
)
For example, hardcoding the name and version:
#!/usr/bin/env nodeimport { runTemplateCLI } from "bingo";
import template from "./template.js";
process.exitCode = await runTemplateCLI(template, { name: "my-example", version: "1.2.3",});
Made with 💝 in Boston by
Josh Goldberg.