mirror of
https://code.forgejo.org/actions/setup-node.git
synced 2025-05-19 21:04:45 +00:00
Add support for asdf format as Node.js version file
This commit is contained in:
parent
82496765f3
commit
dbb64ac1d1
7 changed files with 32 additions and 20 deletions
|
@ -487,12 +487,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 {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue