Skip to content

Latest commit

 

History

History
141 lines (91 loc) · 3.3 KB

02-clang-format-git.md

File metadata and controls

141 lines (91 loc) · 3.3 KB

clang-format-git

NPM Version Node Current

Repository | npm

Node wrapper for git-clang-format Python script as a standalone native binary to allow execution without a Python dependency.

Installation

This package already includes clang-format-node, so there’s no need to install it separately.

global

npm install -g clang-format-git
yarn global add clang-format-git
pnpm add -g clang-format-git
bun add -g clang-format-git

local(devDependencies)

npm install --save-dev clang-format-git
yarn add --dev clang-format-git
pnpm add -D clang-format-git
bun add -d clang-format-git

Usage

You can use the commands below to run git-clang-format.

clang-format-git is an alias for git-clang-format and works in exactly the same way.

npx git-clang-format
npx clang-format-git

Node.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

    const {
      gitClangFormatPath,
      clangFormatGitPath,
      getGitClangFormatPath,
      getClangFormatGitPath,
    } = require('clang-format-git');
  • ES Modules

    import {
      gitClangFormatPath,
      clangFormatGitPath,
      getGitClangFormatPath,
      getClangFormatGitPath,
    } from 'clang-format-git';

gitClangFormatPath

The ABSOLUTE path to the git-clang-format executable binary based on the OS platform and architecture.

Alias and Version

clangFormatGitPath

Alias for gitClangFormatPath.

Alias and Version

getGitClangFormatPath

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 the git-clang-format executable binary.

Throws

  • Error: Throws an error if the executable binary is not found for the specified OS platform and architecture.

Alias and Version

getClangFormatGitPath

Alias for getGitClangFormatPath.

Alias and Version