clang-format-git
Node wrapper for git-clang-format Python script as a standalone native binary to allow execution without a Python dependency.
TIP
This package also supports JSDoc type hints with the following APIs, so you'll see more detailed information directly in your code editor.
Installation
This package already includes clang-format-node as a dependency, so there's no need to install it separately.
# Global
$ npm install -g clang-format-git
# Local
$ npm install -D clang-format-git# Global
$ pnpm add -g clang-format-git
# Local
$ pnpm add -D clang-format-git# Global
$ yarn global add clang-format-git
# Local
$ yarn add --dev clang-format-git# Global
$ bun add -g clang-format-git
# Local
$ bun add -d clang-format-gitCLI Commands
You can use the commands below to run git-clang-format.
NOTE
clang-format-git is an alias for git-clang-format and works in exactly the same way.
npx git-clang-formatnpx clang-format-gitNode.js APIs
These APIs depends on the Node.js fs and path module and the file system, so you cannot use it in browsers.
CommonJS
jsconst { gitClangFormatPath, clangFormatGitPath, getGitClangFormatPath, getClangFormatGitPath, } = require('clang-format-git');ES Modules
jsimport { gitClangFormatPath, clangFormatGitPath, getGitClangFormatPath, getClangFormatGitPath, } from 'clang-format-git';
gitClangFormatPath
Type:
string
The ABSOLUTE path to the git-clang-format executable binary based on the OS platform and architecture.
Alias and Version
- Alias:
clangFormatGitPath. SeeclangFormatGitPath. - Version:
v1.2.0Initial release.
clangFormatGitPath
Type:
string
Alias for gitClangFormatPath.
Alias and Version
- Alias:
gitClangFormatPath. SeegitClangFormatPath. - Version:
v1.2.0Initial release.
getGitClangFormatPath
Type:
function
Returns the ABSOLUTE path to the git-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.
Parameters
- 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)
Returns
string: The absolute path to thegit-clang-formatexecutable binary.
Throws
Error: Throws an error if the executable binary is not found for the specified OS platform and architecture.
Alias and Version
- Alias:
getClangFormatGitPath. SeegetClangFormatGitPath. - Version:
v1.2.0Initial release.
getClangFormatGitPath
Type:
function
Alias for getGitClangFormatPath.
Alias and Version
- Alias:
getGitClangFormatPath. SeegetGitClangFormatPath. - Version:
v1.2.0Initial release.