diff --git a/.githooks/pre-commit b/.githooks/pre-commit new file mode 100755 index 0000000..15ed424 --- /dev/null +++ b/.githooks/pre-commit @@ -0,0 +1,2 @@ +#!/bin/bash +npm run format && git add -A \ No newline at end of file diff --git a/.githooks/setup.sh b/.githooks/setup.sh new file mode 100755 index 0000000..dd4d0c2 --- /dev/null +++ b/.githooks/setup.sh @@ -0,0 +1,4 @@ +#!/bin/bash +git config core.hooksPath .githooks +chmod +x .githooks/* +git config alias.add '!f() { npm run format && git add "$@"; }; f' \ No newline at end of file diff --git a/package.json b/package.json index cadd4a0..27b3e56 100644 --- a/package.json +++ b/package.json @@ -42,6 +42,8 @@ "cli:build": "cross-env NODE_ENV=production rollup -c rollup.config.js", "test": "npm run cli:build && node tests/index.js", "format": "npx prettier --write . --ignore-unknown && cd src-tauri && cargo fmt --verbose", + "hooks:setup": "bash .githooks/setup.sh", + "postinstall": "npm run hooks:setup", "prepublishOnly": "npm run cli:build" }, "type": "module",