Node wrapper for clang-format
native binary inspired by angular/clang-format. (The CORE package.)
If you want to use clang-format
without git-clang-format
, simply follow the installation guide below. If you need git-clang-format
, refer to the clang-format-git
or clang-format-git-python
.
npm install -g clang-format-node
yarn global add clang-format-node
pnpm add -g clang-format-node
bun add -g clang-format-node
npm install --save-dev clang-format-node
yarn add --dev clang-format-node
pnpm add -D clang-format-node
bun add -d clang-format-node
You can use the commands below to run clang-format
.
clang-format-node
is an alias forclang-format
and works in exactly the same way.
npx clang-format
npx clang-format-node
These APIs depends on the Node.js fs
and path
module and the file system, so you cannot use it in browsers.
-
CommonJS
const { clangFormatPath, clangFormatNodePath, getClangFormatPath, getClangFormatNodePath } = require('clang-format-node');
-
ES Modules
import { clangFormatPath, clangFormatNodePath, getClangFormatPath, getClangFormatNodePath } from 'clang-format-node';
The ABSOLUTE path to the clang-format
executable binary based on the OS platform and architecture.
- Alias:
clangFormatNodePath
. SeeclangFormatNodePath
. - Version:
v1.2.0
Initial release.
Alias for clangFormatPath
.
- Alias:
clangFormatPath
. SeeclangFormatPath
. - Version:
v1.2.0
Initial release.
Returns the ABSOLUTE path to the clang-format
executable binary based on the OS platform and architecture.
The possible combinations are darwin-arm64
, darwin-x64
, linux-arm
, linux-arm64
, linux-ppc64
, linux-s390x
, linux-x64
, win32-x64
.
Throws an error if the executable is not found.
- osPlatform (
string
): The current operating system platform. (e.g.,darwin
,linux
,win32
) - architecture (
string
): The current system architecture. (e.g.,arm
,arm64
,ppc64
,s390x
,x64
)
string
: The absolute path to theclang-format
executable binary.
Error
: Throws an error if the executable binary is not found for the specified OS platform and architecture.
- Alias:
getClangFormatNodePath
. SeegetClangFormatNodePath
. - Version:
v1.2.0
Initial release.
Alias for getClangFormatPath
.
- Alias:
getClangFormatPath
. SeegetClangFormatPath
. - Version:
v1.2.0
Initial release.