mirror of
https://github.com/opentofu/setup-opentofu.git
synced 2026-11-29 19:44:21 +01:00
feat: support .tool-versions (asdf format) in tofu_version_file (#131)
Signed-off-by: somaz <genius5711@gmail.com>
This commit is contained in:
1 parent
7f68c568ed
commit
37a417e5ae
4 files changed
+49
-6
No files matched your search
Vendored
+8
-3
@@ -35234,9 +35234,14 @@ async function run () {
|
||||
try {
|
||||
core_debug(`Reading OpenTofu version from file: ${versionFile}`);
|
||||
const fileVersion = await external_fs_namespaceObject.promises.readFile(versionFile, 'utf8');
|
||||
const trimmedVersion = fileVersion.trim();
|
||||
if (trimmedVersion) {
|
||||
version = trimmedVersion;
|
||||
// .tool-versions (asdf format): use the version from the `opentofu <version>`
|
||||
// line and ignore other tool entries. Otherwise (e.g. a single-line
|
||||
// `.opentofu-version` file): use the whole trimmed file content.
|
||||
// Spec: https://asdf-vm.com/manage/configuration.html#tool-versions
|
||||
const asdfMatch = fileVersion.match(/^\s*opentofu\s+([^\s#]+)/m);
|
||||
const parsedVersion = asdfMatch ? asdfMatch[1] : fileVersion.trim();
|
||||
if (parsedVersion) {
|
||||
version = parsedVersion;
|
||||
core_debug(`Using version from file: ${version}`);
|
||||
} else {
|
||||
warning(
|
||||
|
||||
Reference in new issue
Block a user