Skip to content

Transform

transform describes the files a task reads and writes. Rivet uses these paths for freshness checks, and exposes them to command loops.

tasks:
    compile:
        transform:
            subst: 'src/%.old:build/%.new'
            matches:
                - src/**/*.old
            yields:
                - build/{{.TASK}}.stamp
        cmds:
            - for: transform
                cmd: cp "{{.MATCH}}" "{{.YIELD}}"

subst

subst pairs an input pattern with an output pattern using the form from:to. The first % in each pattern is replaced by the same matched stem:

transform:
    subst: '%.old:%.new'

cmds:
    - for: transform
        cmd: cp "{{.MATCH}}" "{{.YIELD}}"

For file_1.old, this produces file_1.new. Directory prefixes can also be changed, for example src/%.old:build/%.new.

With for: transform, each substitution exposes:

  • .MATCH: the input path.
  • .YIELD: the output path generated by the substitution.

matches

matches lists input paths or glob patterns. Matching paths are available to commands with for: matches:

transform:
    matches:
        - file_*.txt
        - '**/*.txt'

cmds:
    - for: matches
        cmd: echo "{{.ITEM}}"

Patterns support exact paths, *, ?, and recursive ** globs. Paths are resolved relative to the task directory. A match is also an input to the task's up-to-date check.

yields

yields lists output paths or glob patterns. They are available to commands with for: yields and are used as task outputs:

transform:
    yields:
        - build/{{.TASK}}.out

cmds:
    - for: yields
        cmd: touch "{{.ITEM}}"

Literal output paths may be declared before the files exist. Patterns are expanded against the filesystem, and may use the same glob syntax as matches.

subst, matches, and yields can be combined in one transform. The loop sources remain independent, so a task can process substitution pairs and also iterate over additional inputs or outputs.