@@ -23,6 +23,7 @@ import { ConfigurationError, getErrorMessage, isDefined } from "./util";
2323 */
2424export enum StartProxyErrorType {
2525 DownloadFailed = "Failed to download proxy archive." ,
26+ ExtractionFailed = "Failed to extract proxy archive." ,
2627}
2728
2829/**
@@ -413,7 +414,7 @@ export function credentialToStr(c: Credential): string {
413414/**
414415 * Attempts to download a file from `url` into the toolcache.
415416 *
416- * @param logger THe logger to use.
417+ * @param logger The logger to use.
417418 * @param url The URL to download the proxy binary from.
418419 * @param authorization The authorization information to use.
419420 * @returns If successful, the path to the downloaded file.
@@ -434,3 +435,21 @@ export async function downloadProxy(
434435 throw new StartProxyError ( StartProxyErrorType . DownloadFailed ) ;
435436 }
436437}
438+
439+ /**
440+ * Attempts to extract the proxy binary from the `archive`.
441+ *
442+ * @param logger The logger to use.
443+ * @param archive The archive to extract.
444+ * @returns The path to the extracted file(s).
445+ */
446+ export async function extractProxy ( logger : Logger , archive : string ) {
447+ try {
448+ return await toolcache . extractTar ( archive ) ;
449+ } catch ( error ) {
450+ logger . error (
451+ `Failed to extract proxy archive from ${ archive } : ${ getErrorMessage ( error ) } ` ,
452+ ) ;
453+ throw new StartProxyError ( StartProxyErrorType . ExtractionFailed ) ;
454+ }
455+ }
0 commit comments