diff --git a/lib/start-proxy-action.js b/lib/start-proxy-action.js index a9e8e7fd9..2bdc411b7 100644 --- a/lib/start-proxy-action.js +++ b/lib/start-proxy-action.js @@ -119806,8 +119806,11 @@ async function cacheProxy(logger, source, filename, version) { throw new StartProxyError("Failed to add proxy to toolcache" /* CacheFailed */); } } +function getProxyFilename() { + return process.platform === "win32" ? `${UPDATEJOB_PROXY}.exe` : UPDATEJOB_PROXY; +} async function getProxyBinaryPath(logger) { - const proxyFileName = process.platform === "win32" ? `${UPDATEJOB_PROXY}.exe` : UPDATEJOB_PROXY; + const proxyFileName = getProxyFilename(); const proxyInfo = await getDownloadUrl(logger); let proxyBin = toolcache.find(proxyFileName, proxyInfo.version); if (!proxyBin) { diff --git a/src/start-proxy.test.ts b/src/start-proxy.test.ts index 6cd1b2e98..f7a0dd707 100644 --- a/src/start-proxy.test.ts +++ b/src/start-proxy.test.ts @@ -1,3 +1,5 @@ +import * as filepath from "path"; + import * as core from "@actions/core"; import * as toolcache from "@actions/tool-cache"; import test, { ExecutionContext } from "ava"; @@ -484,7 +486,10 @@ test("getProxyBinaryPath - returns path from tool cache if available", async (t) const path = await startProxyExports.getProxyBinaryPath(logger); t.assert(path); - t.assert(path.startsWith(toolcachePath)); + t.is( + path, + filepath.join(toolcachePath, startProxyExports.getProxyFilename()), + ); }); }); @@ -525,6 +530,9 @@ test("getProxyBinaryPath - downloads proxy if not in cache", async (t) => { t.assert(cacheDir.calledOnceWith(extractedPath)); t.assert(path); - t.assert(path.startsWith(toolcachePath)); + t.is( + path, + filepath.join(toolcachePath, startProxyExports.getProxyFilename()), + ); }); }); diff --git a/src/start-proxy.ts b/src/start-proxy.ts index 94d373fa1..980eb44b6 100644 --- a/src/start-proxy.ts +++ b/src/start-proxy.ts @@ -486,6 +486,15 @@ export async function cacheProxy( } } +/** + * Returns the platform-specific filename of the proxy binary. + */ +export function getProxyFilename() { + return process.platform === "win32" + ? `${UPDATEJOB_PROXY}.exe` + : UPDATEJOB_PROXY; +} + /** * Gets a path to the proxy binary. If possible, this function will find the proxy in the * runner's tool cache. Otherwise, it downloads and extracts the proxy binary, @@ -495,8 +504,7 @@ export async function cacheProxy( * @returns The path to the proxy binary. */ export async function getProxyBinaryPath(logger: Logger): Promise { - const proxyFileName = - process.platform === "win32" ? `${UPDATEJOB_PROXY}.exe` : UPDATEJOB_PROXY; + const proxyFileName = getProxyFilename(); const proxyInfo = await getDownloadUrl(logger); let proxyBin = toolcache.find(proxyFileName, proxyInfo.version);