diff --git a/src/version.js b/src/version.js index 460788e..763b560 100644 --- a/src/version.js +++ b/src/version.js @@ -57,9 +57,16 @@ function getDenoVersionFromFile(versionFilePath) { const contents = fs.readFileSync(versionFilePath, "utf8"); - const found = contents.match(/^(?:deno?\s+)?v?(?[^\s]+)$/m); + // .tool-versions typically looks like + // ``` + // ruby 2.6.5 + // deno 1.43.1 + // node 20.0.0 + // ``` + // This parses the version of Deno from the file + const denoVersionInToolVersions = contents.match(/^deno\s+v?(?[^\s]+)$/m); - return (found && found.groups && found.groups.version) || contents.trim(); + return denoVersionInToolVersions?.groups?.version || contents.trim(); } /**