mirror of
https://code.forgejo.org/actions/setup-node.git
synced 2025-06-08 13:11:11 +00: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:
parent
ed960c9656
commit
bd33d2e93f
3 changed files with 36 additions and 0 deletions
|
@ -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);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue