Skip to content
This repository has been archived by the owner on Sep 17, 2024. It is now read-only.

ci: make clang-format error when formatting errors are raised. #230

Merged
merged 12 commits into from
Jan 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions clang-format.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { execSync } from "child_process";
import { exit } from "process";
import {error, log} from "console"


const args = ["--Werror", "-i", "--style=file", "bindings/cpu_profiler.cc"];
const cmd = `./node_modules/.bin/clang-format ${args.join(" ")}`;

execSync(cmd)

log("clang-format: done, checking tree...")

const diff = execSync(`git status --short`).toString()

if(diff) {
error("clang-format: check failed ❌")
exit(1)
}

log("clang-format: check passed ✅")

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,10 @@
"clean": "rm -rf ./lib && rm -rf build",
"lint": "npm run lint:eslint && npm run lint:clang",
"lint:eslint": "eslint . --format stylish",
"lint:clang": "./node_modules/.bin/check-clang-format --style=file -i ./**/*.cc",
"lint:clang": "node ./clang-format.mjs",
"fix": "npm run fix:eslint && npm run fix:clang",
"fix:eslint": "eslint . --format stylish --fix",
"fix:clang": "./node_modules/.bin/clang-format --style=file -i ./**/*.cc ",
"fix:clang": "node ./clang-format.mjs --fix",
"build": "npm run build:bindings && npm run build:lib",
"build:lib:esm": "node ./esbuild.esm.mjs",
"build:lib:cjs": "node ./esbuild.cjs.mjs",
Expand Down
Loading