fix: use exec from actions/exec instead of child_process

Also return undefined instead of void
This commit is contained in:
Amin Yahyaabadi 2021-09-16 16:12:29 -05:00
parent 1bafb63779
commit cac52d79f7
3 changed files with 4 additions and 6 deletions

View File

@ -9,6 +9,6 @@ describe("setup-brew", () => {
return
}
const installInfo = setupBrew("", "", "")
await testBin("brew", ["--version"], (installInfo as InstallationInfo | undefined)?.binDir)
await testBin("brew", ["--version"], installInfo?.binDir)
})
})

View File

@ -6,7 +6,7 @@ let binDir: string | undefined
// eslint-disable-next-line @typescript-eslint/no-unused-vars
export function setupBrew(_version: string, _setupCppDir: string, _arch: string) {
if (!["darwin", "linux"].includes(process.platform)) {
return
return undefined
}
if (typeof binDir === "string") {
return { binDir }

View File

@ -1,9 +1,9 @@
import * as io from "@actions/io"
import { tmpdir } from "os"
import * as path from "path"
import { spawnSync as spawn } from "child_process"
import { addBinExtension } from "../setup/setupBin"
import { join } from "path"
import { exec } from "@actions/exec"
export async function setupTmpDir(testName: string) {
const tempDirectory = path.join(tmpdir(), "setup-cpp", testName)
@ -41,9 +41,7 @@ export async function testBin(name: string, args: string[] = ["--version"], binD
bin = join(binDir, addBinExtension(name))
}
const { status } = spawn(bin, args, {
encoding: "utf8",
})
const status = await exec(bin, args)
expect(status).toBe(0)
expect(await io.which(name, true)).toBe(bin)