Code file: keep source in your repo
Goal
Move a block’s source code into a file that’s under source control. Time: 10 minutes.
Code file (kind: code_file) works exactly like Code: it has the same input file, the same last-line rule, and the same seven languages. The difference is that the source lives at path, resolved relative to the workflow’s folder.
Steps
Set the workflow’s folder to a project, for example
~/src/acme-apis.Save this as
scripts/echo.pyin that folder:Add the block:
Rules
- Language is inferred from the extension:
.sh(and unknown extensions) → bash,.ps1→ powershell,.py→ python,.cs→ csharp,.rs→ rust,.js/.mjs→ javascript,.ts→ typescript. Setlanguage:explicitly for an unusual extension. argsis a single string split on whitespace. Shell quoting is not applied:args: --name "Ada Lovelace"becomes three arguments,--name,"Ada, andLovelace". Pass structured values throughusesand the input file instead.- The source is copied into a build directory, and the working directory is the run’s
files/. Relative imports and companion files next to the original don’t resolve. Keep scripts self-contained, or use explicit paths built from$TERMORQ_FOLDER. - Code file isn’t a project launcher: it doesn’t run
cargo,npm install, or.csprojbuilds. - Code file has no Execute step. Test it with a full run (you’ll need a trigger that supplies
trigger.text, or useinputs).
Check your run
steps.from_file.argv is ["--mode","fast","--verbose"].
Exercise
Change args to --greeting "hello world". Predict argv before you run it.