feat: add cppcheck

This commit is contained in:
Amin Yahyaabadi 2021-09-16 03:30:47 -05:00
parent 7957d7f52a
commit a614cdbf27
3 changed files with 35 additions and 1 deletions

View File

@ -21,8 +21,8 @@ The package will be usable from any environment (locally, GitHub Actions, etc).
- [x] setup gcovr
- [x] setup python
- [x] setup msvc
- [x] setup cppcheck
- [ ] setup gcc/mingw
- [ ] setup OpenCppCoverage
- [ ] setup cppcheck
- [ ] setup doxygen
- [ ] setup vcpkg

View File

@ -0,0 +1,14 @@
import { setupCppcheck } from "../cppcheck"
import { spawnSync as spawn } from "child_process"
jest.setTimeout(200000)
describe("setup-cppcheck", () => {
it("should setup cppcheck", async () => {
await setupCppcheck()
const { status } = spawn("cppcheck", ["--version"], {
encoding: "utf8",
})
expect(status).toBe(0)
})
})

20
src/cppcheck/cppcheck.ts Normal file
View File

@ -0,0 +1,20 @@
import { setupAptPack } from "../utils/setup/setupAptPack"
import { setupBrewPack } from "../utils/setup/setupBrewPack"
import { setupChocoPack } from "../utils/setup/setupChocoPack"
export function setupCppcheck(version?: string) {
switch (process.platform) {
case "win32": {
return setupChocoPack("cppcheck", version)
}
case "darwin": {
return setupBrewPack("cppcheck", version)
}
case "linux": {
return setupAptPack("cppcheck", version)
}
default: {
throw new Error(`Unsupported platform`)
}
}
}