mirror of https://github.com/aminya/setup-cpp
fix: use exec from actions/exec instead of child_process
Also return undefined instead of void
This commit is contained in:
parent
1bafb63779
commit
cac52d79f7
|
@ -9,6 +9,6 @@ describe("setup-brew", () => {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
const installInfo = setupBrew("", "", "")
|
const installInfo = setupBrew("", "", "")
|
||||||
await testBin("brew", ["--version"], (installInfo as InstallationInfo | undefined)?.binDir)
|
await testBin("brew", ["--version"], installInfo?.binDir)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
|
@ -6,7 +6,7 @@ let binDir: string | undefined
|
||||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||||
export function setupBrew(_version: string, _setupCppDir: string, _arch: string) {
|
export function setupBrew(_version: string, _setupCppDir: string, _arch: string) {
|
||||||
if (!["darwin", "linux"].includes(process.platform)) {
|
if (!["darwin", "linux"].includes(process.platform)) {
|
||||||
return
|
return undefined
|
||||||
}
|
}
|
||||||
if (typeof binDir === "string") {
|
if (typeof binDir === "string") {
|
||||||
return { binDir }
|
return { binDir }
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
import * as io from "@actions/io"
|
import * as io from "@actions/io"
|
||||||
import { tmpdir } from "os"
|
import { tmpdir } from "os"
|
||||||
import * as path from "path"
|
import * as path from "path"
|
||||||
import { spawnSync as spawn } from "child_process"
|
|
||||||
import { addBinExtension } from "../setup/setupBin"
|
import { addBinExtension } from "../setup/setupBin"
|
||||||
import { join } from "path"
|
import { join } from "path"
|
||||||
|
import { exec } from "@actions/exec"
|
||||||
|
|
||||||
export async function setupTmpDir(testName: string) {
|
export async function setupTmpDir(testName: string) {
|
||||||
const tempDirectory = path.join(tmpdir(), "setup-cpp", testName)
|
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))
|
bin = join(binDir, addBinExtension(name))
|
||||||
}
|
}
|
||||||
|
|
||||||
const { status } = spawn(bin, args, {
|
const status = await exec(bin, args)
|
||||||
encoding: "utf8",
|
|
||||||
})
|
|
||||||
expect(status).toBe(0)
|
expect(status).toBe(0)
|
||||||
|
|
||||||
expect(await io.which(name, true)).toBe(bin)
|
expect(await io.which(name, true)).toBe(bin)
|
||||||
|
|
Loading…
Reference in New Issue