From 28f7f1fb278d54100958dbc4f77de95e0bbe6fd3 Mon Sep 17 00:00:00 2001 From: Amin Yahyaabadi Date: Thu, 16 Sep 2021 15:08:54 -0500 Subject: [PATCH] fix: fix binDir for choco --- src/chocolatey/chocolatey.ts | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/chocolatey/chocolatey.ts b/src/chocolatey/chocolatey.ts index a980c594..777fdf86 100644 --- a/src/chocolatey/chocolatey.ts +++ b/src/chocolatey/chocolatey.ts @@ -1,4 +1,5 @@ import { exec } from "@actions/exec" +import { existsSync } from "fs" import which from "which" import { InstallationInfo } from "../utils/setup/setupBin" @@ -35,5 +36,11 @@ export async function setupChocolatey( throw new Error(`Failed to install chocolatey`) } - return { binDir: which.sync("choco", { nothrow: true }) ?? "C:\\ProgramData\\Chocolatey\\bin\\" } + // eslint-disable-next-line require-atomic-updates + binDir = which.sync("choco", { nothrow: true }) ?? "C:\\ProgramData\\Chocolatey\\bin\\" + + if (existsSync(binDir)) { + return { binDir } + } + return undefined }