Skip to content

runtime.star

Set language versions in version files: .nvmrc, .python-version, .tool-versions and friends.

load("@fleet//runtime.star", "version", "set_version")
Function What it does
version Reads the version a repo pins for a runtime.
set_version Sets a runtime's version in every version file the repo already has.

version

version(repo, runtime)

Reads the version a repo pins for a runtime.

Dedicated files such as .nvmrc are read before .tool-versions.

Arguments

Name Description
repo The repo passed to change(repo).
runtime One of node, python, ruby, go, java, terraform, elixir, erlang or rust.

Returns: The version as written, or None when nothing pins it.

Example

version(repo, "node")
# returns "20.11.0"

.tool-versions

nodejs 20.11.0
python 3.12.1

Source

set_version

set_version(repo, runtime, version, create = None)

Sets a runtime's version in every version file the repo already has.

A newer version already pinned is kept, and so are aliases such as lts/*.

Updates the dedicated files (.nvmrc and .node-version for node, .python-version for python, and so on) and the runtime's line in .tool-versions. A repo that pins the runtime nowhere is left alone unless create is set.

Arguments

Name Description
repo The repo passed to change(repo).
runtime One of node, python, ruby, go, java, terraform, elixir, erlang or rust.
version The version to pin, such as 22 or 3.12.7.
create A file to write, such as .nvmrc, when nothing pins the runtime yet.

Returns: The list of paths that changed.

Example

set_version(repo, "node", "22")
# returns [".nvmrc", ".tool-versions"]

.nvmrc

20

.tool-versions

nodejs 20.11.0
python 3.12.1

.nvmrc

22

.tool-versions

nodejs 22
python 3.12.1

Used in: elixir-phoenix, node-version, python-version

Source