mirror of
https://code.forgejo.org/actions/setup-node.git
synced 2025-05-19 12:54:45 +00:00
Support lts/-n aliases (#481)
This commit is contained in:
parent
ed1a46e9f2
commit
eeb10cff27
6 changed files with 309 additions and 302 deletions
|
@ -223,13 +223,21 @@ function resolveLtsAliasFromManifest(
|
|||
|
||||
core.debug(`LTS alias '${alias}' for Node version '${versionSpec}'`);
|
||||
|
||||
// Supported formats are `lts/<alias>` and `lts/*`. Where asterisk means highest possible LTS.
|
||||
// Supported formats are `lts/<alias>`, `lts/*`, and `lts/-n`. Where asterisk means highest possible LTS and -n means the nth-highest.
|
||||
const n = Number(alias);
|
||||
const aliases = Object.fromEntries(
|
||||
manifest
|
||||
.filter(x => x.lts && x.stable === stable)
|
||||
.map(x => [x.lts!.toLowerCase(), x])
|
||||
.reverse()
|
||||
);
|
||||
const numbered = Object.values(aliases);
|
||||
const release =
|
||||
alias === '*'
|
||||
? manifest.find(x => !!x.lts && x.stable === stable)
|
||||
: manifest.find(
|
||||
x => x.lts?.toLowerCase() === alias && x.stable === stable
|
||||
);
|
||||
? numbered[numbered.length - 1]
|
||||
: n < 0
|
||||
? numbered[numbered.length - 1 + n]
|
||||
: aliases[alias];
|
||||
|
||||
if (!release) {
|
||||
throw new Error(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue