From a39b19b5783af728710b5d261a267c9792092606 Mon Sep 17 00:00:00 2001 From: Ayoub-Mabrouk Date: Tue, 5 Nov 2024 01:00:08 +0100 Subject: [PATCH] Refactor getVersionFromToolVersionsFile function - Simplified parameter handling by providing a default value directly in the function signature. - Improved readability by removing unnecessary variable assignment. --- lib/versions.js | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/lib/versions.js b/lib/versions.js index ab20ecb..6c47076 100644 --- a/lib/versions.js +++ b/lib/versions.js @@ -106,14 +106,13 @@ function fetchLatestTag(repo) { ); } -async function getVersionFromToolVersionsFile(toolVersionsPath) { +async function getVersionFromToolVersionsFile(toolVersionsPath = ".tool-versions") { try { - toolVersionsPath = toolVersionsPath || ".tool-versions"; const toolVersions = await fs.readFile(toolVersionsPath, { - encoding: "utf-8", + encoding: "utf-8" }); return toolVersions.match(/^scarb ([\w.-]+)/m)?.[1]; - } catch (e) { + } catch { return undefined; } }