Allow using .tool-versions for node-version-file

This enables developers which use `asdf` to use their version file

Signed-off-by: Timo Sand <timo.sand@iki.fi>
This commit is contained in:
Timo Sand 2022-03-15 22:40:41 +02:00
parent ed960c9656
commit bd33d2e93f
No known key found for this signature in database
GPG key ID: A9A4F4CA7A0DB372
3 changed files with 36 additions and 0 deletions

View file

@ -468,6 +468,14 @@ function translateArchToDistUrl(arch: string): string {
export function parseNodeVersionFile(contents: string): string {
let nodeVersion = contents.trim();
if (contents.indexOf('nodejs') !== -1) {
const lineWithNodeJsVersions = contents.match(/^nodejs.*$/gm);
const firstLineWithNodeJsVersion =
lineWithNodeJsVersions && lineWithNodeJsVersions[0];
nodeVersion =
firstLineWithNodeJsVersion?.replace('nodejs', '').trim() || nodeVersion;
}
if (/^v\d/.test(nodeVersion)) {
nodeVersion = nodeVersion.substring(1);
}