From 8313d9142bc02e24357b55b84d72befb491a271e Mon Sep 17 00:00:00 2001 From: Tw93 Date: Thu, 14 Aug 2025 15:10:54 +0800 Subject: [PATCH] :sparkles: Automatically format when submitting --- .githooks/pre-commit | 2 ++ .githooks/setup.sh | 4 ++++ package.json | 2 ++ 3 files changed, 8 insertions(+) create mode 100755 .githooks/pre-commit create mode 100755 .githooks/setup.sh 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",