From a7b5311f2bcf06d5385bc89081c9292eba046888 Mon Sep 17 00:00:00 2001
From: Aparna Jyothi <aparnajyothi-y@github.com>
Date: Thu, 30 Jan 2025 15:37:56 +0530
Subject: [PATCH] check-latest

---
 action.yml                                           | 2 +-
 dist/setup/index.js                                  | 6 +++++-
 src/distributions/official_builds/official_builds.ts | 5 +++++
 src/main.ts                                          | 2 +-
 4 files changed, 12 insertions(+), 3 deletions(-)

diff --git a/action.yml b/action.yml
index a98f1fe9..3cd51852 100644
--- a/action.yml
+++ b/action.yml
@@ -14,7 +14,7 @@ inputs:
   check-latest:
     description: 'Set this option if you want the action to check for the latest available version that satisfies the version spec.'
     default: false
-  mirrorURL:
+  mirror-url:
     description: 'Custom mirror URL to download Node.js from (optional)'
     required: false
   registry-url:
diff --git a/dist/setup/index.js b/dist/setup/index.js
index ab183ef2..0111cbdd 100644
--- a/dist/setup/index.js
+++ b/dist/setup/index.js
@@ -100668,6 +100668,10 @@ class OfficialBuilds extends base_distribution_1.default {
             const nodeJsVersions = yield this.getNodeJsVersions();
             const versions = this.filterVersions(nodeJsVersions);
             const evaluatedVersion = this.evaluateVersions(versions);
+            if (this.nodeInfo.checkLatest) {
+                const evaluatedVersion = yield this.findVersionInDist(nodeJsVersions);
+                this.nodeInfo.versionSpec = evaluatedVersion;
+            }
             if (!evaluatedVersion) {
                 throw new Error(`Unable to find Node version '${this.nodeInfo.versionSpec}' for platform ${this.osPlat} and architecture ${this.nodeInfo.arch}.`);
             }
@@ -100808,7 +100812,7 @@ function run() {
             if (!arch) {
                 arch = os_1.default.arch();
             }
-            const mirrorURL = core.getInput('mirrorURL').trim(); // .trim() to remove any accidental spaces
+            const mirrorURL = core.getInput('mirror-url').trim(); // .trim() to remove any accidental spaces
             if (version) {
                 const token = core.getInput('token');
                 const auth = !token ? undefined : `token ${token}`;
diff --git a/src/distributions/official_builds/official_builds.ts b/src/distributions/official_builds/official_builds.ts
index 7f8b65b7..22eab867 100644
--- a/src/distributions/official_builds/official_builds.ts
+++ b/src/distributions/official_builds/official_builds.ts
@@ -318,6 +318,11 @@ export default class OfficialBuilds extends BaseDistribution {
     const versions = this.filterVersions(nodeJsVersions);
     const evaluatedVersion = this.evaluateVersions(versions);
 
+    if (this.nodeInfo.checkLatest) {
+      const evaluatedVersion = await this.findVersionInDist(nodeJsVersions);
+      this.nodeInfo.versionSpec = evaluatedVersion;
+    }
+
     if (!evaluatedVersion) {
       throw new Error(
         `Unable to find Node version '${this.nodeInfo.versionSpec}' for platform ${this.osPlat} and architecture ${this.nodeInfo.arch}.`
diff --git a/src/main.ts b/src/main.ts
index a3856ace..4face073 100644
--- a/src/main.ts
+++ b/src/main.ts
@@ -33,7 +33,7 @@ export async function run() {
       arch = os.arch();
     }
 
-    const mirrorURL = core.getInput('mirrorURL').trim(); // .trim() to remove any accidental spaces
+    const mirrorURL = core.getInput('mirror-url').trim(); // .trim() to remove any accidental spaces
 
 
     if (version) {