From 064da1045ccd7041d5f730bd1db8c5d9509a70ff Mon Sep 17 00:00:00 2001 From: Amin Yahyaabadi Date: Wed, 15 Sep 2021 03:38:26 -0500 Subject: [PATCH] perf: cache checking choco installation --- src/utils/setup/setupChocoPack.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/utils/setup/setupChocoPack.ts b/src/utils/setup/setupChocoPack.ts index 9d6ec262..81998d21 100644 --- a/src/utils/setup/setupChocoPack.ts +++ b/src/utils/setup/setupChocoPack.ts @@ -1,11 +1,15 @@ +/* eslint-disable require-atomic-updates */ import { exec } from "@actions/exec" import which from "which" import { setupChocolatey } from "../../chocolatey/chocolatey" +let hasChoco = false + /** A function that installs a package using choco */ export async function setupChocoPack(name: string, version?: string) { - if (which.sync("choco", { nothrow: true }) === null) { + if (!hasChoco || which.sync("choco", { nothrow: true }) === null) { await setupChocolatey() + hasChoco = true } let exit