-
Notifications
You must be signed in to change notification settings - Fork 37
Expand file tree
/
Copy pathcppcheck.ts
More file actions
43 lines (41 loc) · 1.42 KB
/
Copy pathcppcheck.ts
File metadata and controls
43 lines (41 loc) · 1.42 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
import { addPath } from "envosman"
import { hasApk, installApkPack } from "setup-alpine"
import { hasAptGet, installAptPack } from "setup-apt"
import { installBrewPack } from "setup-brew"
import { hasDnf, setupDnfPack } from "setup-dnf"
import { isArch, setupPacmanPack } from "setup-pacman"
import { rcOptions } from "../options.js"
import type { SetupOptions } from "../setup-options.js"
import { setupChocoPack } from "../utils/setup-choco.js"
export async function setupCppcheck({ version }: Partial<Pick<SetupOptions, "version">> = {}) {
switch (process.platform) {
case "win32": {
await setupChocoPack("cppcheck", version)
const binDir = await activateWinCppcheck()
return { binDir }
}
case "darwin": {
return installBrewPack("cppcheck", version)
}
case "linux": {
if (isArch()) {
return setupPacmanPack("cppcheck", version)
} else if (hasDnf()) {
return setupDnfPack([{ name: "ccache", version }])
} else if (hasAptGet()) {
return installAptPack([{ name: "cppcheck", version }])
} else if (await hasApk()) {
return installApkPack([{ name: "cppcheck", version }])
}
throw new Error("Unsupported linux distribution")
}
default: {
throw new Error("Unsupported platform")
}
}
}
async function activateWinCppcheck() {
const binDir = "C:/Program Files/Cppcheck"
await addPath(binDir, rcOptions)
return binDir
}