diff --git a/package.json b/package.json index 7b1e4ce4..c9933110 100644 --- a/package.json +++ b/package.json @@ -35,8 +35,7 @@ "Chrome 91" ], "simple-git-hooks": { - "pre-commit": "npx lint-staged", - "pre-push": "npm run typecheck" + "pre-commit": "./scripts/tsc-staged.sh && npx lint-staged" }, "lint-staged": { "*.{js,ts,vue}": "eslint --cache --fix" diff --git a/scripts/tsc-staged.sh b/scripts/tsc-staged.sh new file mode 100644 index 00000000..748d83ee --- /dev/null +++ b/scripts/tsc-staged.sh @@ -0,0 +1,26 @@ +#!/bin/bash + +staged=$(git diff --name-only --cached | grep -E "(tsconfig.json|.ts|.vue)$") + +args=() + +if [[ "$staged" == *"packages/main"* ]]; then + args=("${args[@]}" "npm:typecheck:main") +fi + +if [[ "$staged" == *"packages/preload"* ]]; then + args=("${args[@]}" "npm:typecheck:preload") + +fi + +if [[ "$staged" == *"packages/renderer"* ]]; then + args=("${args[@]}" "npm:typecheck:renderer") +fi + +# shellcheck disable=SC2128 +if [ -z "$args" ]; then + echo "No type sensitivity files staged" +else + node scripts/buildEnvTypes.js + npx concurrently --raw "${args[@]}" +fi