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

Commit

Permalink
ci: make clang-format error when formatting errors are raised. (#230)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
JonasBa authored Jan 8, 2024
1 parent 779867d commit f002b15
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 2 deletions.
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

0 comments on commit f002b15

Please sign in to comment.