Merge pull request #373 from ganta/add-support-for-asdf-format-as-node-version-file

Add support for asdf format as Node.js version file
This commit is contained in:
Marko Zivic 2022-07-11 13:48:55 +02:00 committed by GitHub
commit 5b949b50c3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 42 additions and 11 deletions

View file

@ -495,12 +495,16 @@ function translateArchToDistUrl(arch: string): string {
}
export function parseNodeVersionFile(contents: string): string {
let nodeVersion = contents.trim();
const found = contents.match(/^(?:nodejs\s+)?v?(?<version>[^\s]+)$/m);
const nodeVersion = found?.groups?.version;
if (/^v\d/.test(nodeVersion)) {
nodeVersion = nodeVersion.substring(1);
if (nodeVersion) {
return nodeVersion;
}
return nodeVersion;
// In the case of an unknown format,
// return as is and evaluate the version separately.
return contents.trim();
}
function isLatestSyntax(versionSpec): boolean {