@polycam/clang-tools
v22.1.8
Published
Pinned, cross-platform clang-format and clang-tidy binaries. The npm version is the LLVM version.
Readme
@polycam/clang-tools
Pinned, cross-platform clang tooling, distributed as an npm package. The npm
version is the LLVM version — install @polycam/[email protected] and you get
these tools from LLVM 22.1.8 on every platform, with no compiler, no Python, and
no custom Homebrew tap:
clang-formatclang-tidyclang-apply-replacements— apply clang-tidy's serialized fixes across a compile DBclang-query— interactively match the AST (for authoring query-based custom checks)
yarn add -D @polycam/[email protected]
# then:
npx clang-format --version # clang-format version 22.1.8
npx clang-tidy --version # LLVM version 22.1.8The binaries are LLVM's own official release binaries, repackaged per platform.
The C++-parsing tools (clang-tidy, clang-query) ship clang's builtin-header
resource dir (lib/clang/<major>/include) alongside the binary, so they work
with no -resource-dir fiddling.
Supported platforms
| platform package | os | cpu |
| ------------------------------------ | ------ | ----- |
| @polycam/clang-tools-darwin-arm64 | darwin | arm64 |
| @polycam/clang-tools-linux-x64 | linux | x64 |
| @polycam/clang-tools-win32-x64 | win32 | x64 |
npm installs only the one matching the host (via os/cpu fields), so you
never download binaries for platforms you don't use.
Programmatic API
For build scripts and pre-commit hooks that want the binary path directly (e.g. to avoid a Node-shim spawn per file in a parallel batch):
const { clangFormatPath, clangTidyPath, resolveBinary, run } = require("@polycam/clang-tools");
clangFormatPath(); // → /abs/.../node_modules/@polycam/clang-tools-darwin-arm64/bin/clang-format
resolveBinary("clang-query"); // any of the four tools
run("clang-format", ["--version"]); // spawnSync, inherits stdioConvenience path accessors: clangFormatPath(), clangTidyPath(),
clangApplyReplacementsPath(), clangQueryPath().
From a shell script:
clang_format="$(node -e "console.log(require('@polycam/clang-tools').clangFormatPath())")"Environment overrides
CLANG_FORMAT_PATH/CLANG_TIDY_PATH/CLANG_APPLY_REPLACEMENTS_PATH/CLANG_QUERY_PATH— absolute path to a binary to use instead of the bundled one (development / system binary).
Also available as raw binaries
Every release attaches the standalone binaries (plus .sha512 checksums) to its
GitHub release, for consumers
that would rather curl a binary than pull an npm package.
