fix: fix choco path

This commit is contained in:
Amin Yahyaabadi 2021-09-16 17:44:13 -05:00
parent df6ee47b06
commit 6925e1f02c
1 changed files with 8 additions and 2 deletions

View File

@ -1,5 +1,7 @@
/* eslint-disable require-atomic-updates */
import { exec } from "@actions/exec"
import { existsSync } from "fs"
import { dirname } from "path"
import which from "which"
import { InstallationInfo } from "../utils/setup/setupBin"
@ -36,8 +38,12 @@ export async function setupChocolatey(
throw new Error(`Failed to install chocolatey`)
}
// eslint-disable-next-line require-atomic-updates
binDir = which.sync("choco", { nothrow: true }) ?? "C:\\ProgramData\\Chocolatey\\bin\\"
const maybeChoco = which.sync("choco", { nothrow: true })
if (maybeChoco !== null) {
binDir = dirname(maybeChoco)
} else {
binDir = "C:\\ProgramData\\Chocolatey\\bin\\"
}
if (existsSync(binDir)) {
return { binDir }