mirror of
https://github.com/actions/setup-node.git
synced 2025-12-17 02:31:38 +08:00
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:
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user