Skip to content

Commit

Permalink
Refactor getVersionFromToolVersionsFile function
Browse files Browse the repository at this point in the history
- Simplified parameter handling by providing a default value directly in the function signature.
- Improved readability by removing unnecessary variable assignment.
  • Loading branch information
Ayoub-Mabrouk committed Nov 5, 2024
1 parent f4e6c94 commit a39b19b
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions lib/versions.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}

0 comments on commit a39b19b

Please sign in to comment.