From 6ecdea2b649cf54f04d23e9235d7a28e626bb247 Mon Sep 17 00:00:00 2001 From: Sergey Dolin Date: Thu, 27 Jul 2023 19:29:58 +0200 Subject: [PATCH] Add .tool-versions support --- dist/setup/index.js | 4 ++++ src/installer.ts | 3 +++ 2 files changed, 7 insertions(+) diff --git a/dist/setup/index.js b/dist/setup/index.js index 378197f56..ecad328dd 100644 --- a/dist/setup/index.js +++ b/dist/setup/index.js @@ -61596,6 +61596,10 @@ function parseGoVersionFile(versionFilePath) { const match = contents.match(/^go (\d+(\.\d+)*)/m); return match ? match[1] : ''; } + else if (path.basename(versionFilePath) === '.tool-versions') { + const match = contents.match(/^golang\s+(\d+(\.\d+)*)/m); + return match ? match[1] : ''; + } return contents.trim(); } exports.parseGoVersionFile = parseGoVersionFile; diff --git a/src/installer.ts b/src/installer.ts index 013fb6405..618d2bb07 100644 --- a/src/installer.ts +++ b/src/installer.ts @@ -361,6 +361,9 @@ export function parseGoVersionFile(versionFilePath: string): string { ) { const match = contents.match(/^go (\d+(\.\d+)*)/m); return match ? match[1] : ''; + } else if (path.basename(versionFilePath) === '.tool-versions') { + const match = contents.match(/^golang\s+(\d+(\.\d+)*)/m); + return match ? match[1] : ''; } return contents.trim();