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

Commit f002b15

Browse files
authored
ci: make clang-format error when formatting errors are raised. (#230)
* fix: cleanup timer and reuse exports * add cmd script for clang-format * add cmd * revert profiler changes * test * test * test * test * test * test commiting bad formatting * fix lint
1 parent 779867d commit f002b15

File tree

2 files changed

+23
-2
lines changed

2 files changed

+23
-2
lines changed

clang-format.mjs

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import { execSync } from "child_process";
2+
import { exit } from "process";
3+
import {error, log} from "console"
4+
5+
6+
const args = ["--Werror", "-i", "--style=file", "bindings/cpu_profiler.cc"];
7+
const cmd = `./node_modules/.bin/clang-format ${args.join(" ")}`;
8+
9+
execSync(cmd)
10+
11+
log("clang-format: done, checking tree...")
12+
13+
const diff = execSync(`git status --short`).toString()
14+
15+
if(diff) {
16+
error("clang-format: check failed ❌")
17+
exit(1)
18+
}
19+
20+
log("clang-format: check passed ✅")
21+

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,10 @@
3232
"clean": "rm -rf ./lib && rm -rf build",
3333
"lint": "npm run lint:eslint && npm run lint:clang",
3434
"lint:eslint": "eslint . --format stylish",
35-
"lint:clang": "./node_modules/.bin/check-clang-format --style=file -i ./**/*.cc",
35+
"lint:clang": "node ./clang-format.mjs",
3636
"fix": "npm run fix:eslint && npm run fix:clang",
3737
"fix:eslint": "eslint . --format stylish --fix",
38-
"fix:clang": "./node_modules/.bin/clang-format --style=file -i ./**/*.cc ",
38+
"fix:clang": "node ./clang-format.mjs --fix",
3939
"build": "npm run build:bindings && npm run build:lib",
4040
"build:lib:esm": "node ./esbuild.esm.mjs",
4141
"build:lib:cjs": "node ./esbuild.cjs.mjs",

0 commit comments

Comments
 (0)