Skip to content

Commit beb9f53

Browse files
committed
Add and use getProxyFilename
1 parent a1c7078 commit beb9f53

File tree

3 files changed

+24
-5
lines changed

3 files changed

+24
-5
lines changed

lib/start-proxy-action.js

Lines changed: 4 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/start-proxy.test.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import * as filepath from "path";
2+
13
import * as core from "@actions/core";
24
import * as toolcache from "@actions/tool-cache";
35
import test, { ExecutionContext } from "ava";
@@ -484,7 +486,10 @@ test("getProxyBinaryPath - returns path from tool cache if available", async (t)
484486
const path = await startProxyExports.getProxyBinaryPath(logger);
485487

486488
t.assert(path);
487-
t.assert(path.startsWith(toolcachePath));
489+
t.is(
490+
path,
491+
filepath.join(toolcachePath, startProxyExports.getProxyFilename()),
492+
);
488493
});
489494
});
490495

@@ -525,6 +530,9 @@ test("getProxyBinaryPath - downloads proxy if not in cache", async (t) => {
525530
t.assert(cacheDir.calledOnceWith(extractedPath));
526531

527532
t.assert(path);
528-
t.assert(path.startsWith(toolcachePath));
533+
t.is(
534+
path,
535+
filepath.join(toolcachePath, startProxyExports.getProxyFilename()),
536+
);
529537
});
530538
});

src/start-proxy.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -486,6 +486,15 @@ export async function cacheProxy(
486486
}
487487
}
488488

489+
/**
490+
* Returns the platform-specific filename of the proxy binary.
491+
*/
492+
export function getProxyFilename() {
493+
return process.platform === "win32"
494+
? `${UPDATEJOB_PROXY}.exe`
495+
: UPDATEJOB_PROXY;
496+
}
497+
489498
/**
490499
* Gets a path to the proxy binary. If possible, this function will find the proxy in the
491500
* runner's tool cache. Otherwise, it downloads and extracts the proxy binary,
@@ -495,8 +504,7 @@ export async function cacheProxy(
495504
* @returns The path to the proxy binary.
496505
*/
497506
export async function getProxyBinaryPath(logger: Logger): Promise<string> {
498-
const proxyFileName =
499-
process.platform === "win32" ? `${UPDATEJOB_PROXY}.exe` : UPDATEJOB_PROXY;
507+
const proxyFileName = getProxyFilename();
500508
const proxyInfo = await getDownloadUrl(logger);
501509

502510
let proxyBin = toolcache.find(proxyFileName, proxyInfo.version);

0 commit comments

Comments
 (0)