feat: add support for lts alias

This commit is contained in:
zdm 2024-11-05 09:47:55 +02:00
parent 39370e3970
commit 9656da02e3
2 changed files with 4 additions and 2 deletions

View file

@ -21,7 +21,7 @@ See [action.yml](action.yml)
- uses: actions/setup-node@v4 - uses: actions/setup-node@v4
with: with:
# Version Spec of the version to use in SemVer notation. # Version Spec of the version to use in SemVer notation.
# It also admits such aliases as lts/*, latest, nightly and canary builds # It also admits such aliases as lts, lts/*, latest, nightly and canary builds
# Examples: 12.x, 10.15.1, >=10.15.0, lts/Hydrogen, 16-nightly, latest, node # Examples: 12.x, 10.15.1, >=10.15.0, lts/Hydrogen, 16-nightly, latest, node
node-version: '' node-version: ''
@ -105,7 +105,7 @@ Examples:
- Major versions: `18`, `20` - Major versions: `18`, `20`
- More specific versions: `10.15`, `16.15.1` , `18.4.0` - More specific versions: `10.15`, `16.15.1` , `18.4.0`
- NVM LTS syntax: `lts/erbium`, `lts/fermium`, `lts/*`, `lts/-n` - NVM LTS syntax: `lts`, `lts/erbium`, `lts/fermium`, `lts/*`, `lts/-n`
- Latest release: `*` or `latest`/`current`/`node` - Latest release: `*` or `latest`/`current`/`node`
**Note:** Like the other values, `*` will get the latest [locally-cached Node.js version](https://github.com/actions/runner-images/blob/main/images/ubuntu/Ubuntu2204-Readme.md#nodejs), or the latest version from [actions/node-versions](https://github.com/actions/node-versions/blob/main/versions-manifest.json), depending on the [`check-latest`](docs/advanced-usage.md#check-latest-version) input. **Note:** Like the other values, `*` will get the latest [locally-cached Node.js version](https://github.com/actions/runner-images/blob/main/images/ubuntu/Ubuntu2204-Readme.md#nodejs), or the latest version from [actions/node-versions](https://github.com/actions/node-versions/blob/main/versions-manifest.json), depending on the [`check-latest`](docs/advanced-usage.md#check-latest-version) input.

View file

@ -195,6 +195,8 @@ export default class OfficialBuilds extends BaseDistribution {
stable: boolean, stable: boolean,
manifest: INodeRelease[] manifest: INodeRelease[]
): string { ): string {
if ( versionSpec === "lts" ) versionSpec = "lts/*";
const alias = versionSpec.split('lts/')[1]?.toLowerCase(); const alias = versionSpec.split('lts/')[1]?.toLowerCase();
if (!alias) { if (!alias) {