From 10fc7a6ffed10929d861e07b4006a22e6e327954 Mon Sep 17 00:00:00 2001 From: Alex Kozack Date: Wed, 2 Jun 2021 11:40:20 +0300 Subject: [PATCH] =?UTF-8?q?chore:=20=D0=9F=D1=80=D0=BE=D0=B2=D0=B5=D1=80?= =?UTF-8?q?=D0=BA=D0=B0=20=D1=82=D0=B8=D0=BF=D0=BE=D0=B2=20=D0=B2=20`pre-c?= =?UTF-8?q?ommit`?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Вместо проверки типов по всему проекту в `pre-push` теперь выполняется проверка в `pre-commit` и только в staged `.ts` и `.vue` файлах --- package.json | 3 +-- scripts/tsc-staged.sh | 26 ++++++++++++++++++++++++++ 2 files changed, 27 insertions(+), 2 deletions(-) create mode 100644 scripts/tsc-staged.sh 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