forked from cory/tildefriends
build: add husky to automatically format code
- husky installs a git hook to run make format every time you commit new code - if `make format` fails (if a dependency is missing or prettier throws an error), the hook will still succeed as to not block people for dumb reasons - pin prettier and husky to 3.2.5 and 9.0.11 respectively - add prettier as a dependency for the `make format` rule
This commit is contained in:
parent
71329c5532
commit
5e72c9caf4
1
.husky/pre-commit
Normal file
1
.husky/pre-commit
Normal file
@ -0,0 +1 @@
|
|||||||
|
make format || exit 0
|
@ -2,6 +2,7 @@ node_modules
|
|||||||
src
|
src
|
||||||
deps
|
deps
|
||||||
.clang-format
|
.clang-format
|
||||||
|
flake.lock
|
||||||
|
|
||||||
# Minified files
|
# Minified files
|
||||||
**/*.min.css
|
**/*.min.css
|
||||||
|
@ -902,7 +902,7 @@ dist-test: dist
|
|||||||
@rm -rf tildefriends-$(VERSION_NUMBER)
|
@rm -rf tildefriends-$(VERSION_NUMBER)
|
||||||
.PHONY: dist-test
|
.PHONY: dist-test
|
||||||
|
|
||||||
format:
|
format: prettier
|
||||||
@clang-format -i $(wildcard src/*.c src/*.h src/*.m)
|
@clang-format -i $(wildcard src/*.c src/*.h src/*.m)
|
||||||
.PHONY: format
|
.PHONY: format
|
||||||
|
|
||||||
|
21
package-lock.json
generated
21
package-lock.json
generated
@ -6,12 +6,29 @@
|
|||||||
"": {
|
"": {
|
||||||
"name": "tildefriends",
|
"name": "tildefriends",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"devDependencies": {
|
||||||
"prettier": "^3.2.5"
|
"husky": "9.0.11",
|
||||||
|
"prettier": "3.2.5"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/husky": {
|
||||||
|
"version": "9.0.11",
|
||||||
|
"resolved": "https://registry.npmjs.org/husky/-/husky-9.0.11.tgz",
|
||||||
|
"integrity": "sha512-AB6lFlbwwyIqMdHYhwPe+kjOC3Oc5P3nThEoW/AaO2BX3vJDjWPFxYLxokUZOo6RNX20He3AaT8sESs9NJcmEw==",
|
||||||
|
"dev": true,
|
||||||
|
"bin": {
|
||||||
|
"husky": "bin.mjs"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">=18"
|
||||||
|
},
|
||||||
|
"funding": {
|
||||||
|
"url": "https://github.com/sponsors/typicode"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/prettier": {
|
"node_modules/prettier": {
|
||||||
"version": "3.2.5",
|
"version": "3.2.5",
|
||||||
|
"dev": true,
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"bin": {
|
"bin": {
|
||||||
"prettier": "bin/prettier.cjs"
|
"prettier": "bin/prettier.cjs"
|
||||||
|
@ -1,11 +1,13 @@
|
|||||||
{
|
{
|
||||||
"name": "tildefriends",
|
"name": "tildefriends",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"prettier": "prettier . --check --cache --write"
|
"prettier": "prettier . --check --cache --write",
|
||||||
|
"prepare": "husky"
|
||||||
},
|
},
|
||||||
"author": "Cory McWilliams",
|
"author": "Cory McWilliams",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"devDependencies": {
|
||||||
"prettier": "^3.2.5"
|
"prettier": "3.2.5",
|
||||||
|
"husky": "9.0.11"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user