perf: cache checking choco installation

This commit is contained in:
Amin Yahyaabadi 2021-09-15 03:38:26 -05:00
parent edd8e55e9a
commit 064da1045c
1 changed files with 5 additions and 1 deletions

View File

@ -1,11 +1,15 @@
/* eslint-disable require-atomic-updates */
import { exec } from "@actions/exec" import { exec } from "@actions/exec"
import which from "which" import which from "which"
import { setupChocolatey } from "../../chocolatey/chocolatey" import { setupChocolatey } from "../../chocolatey/chocolatey"
let hasChoco = false
/** A function that installs a package using choco */ /** A function that installs a package using choco */
export async function setupChocoPack(name: string, version?: string) { 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() await setupChocolatey()
hasChoco = true
} }
let exit let exit