From e3cff00e72623f9aec2a0a415063f96dc03ab92e Mon Sep 17 00:00:00 2001 From: Jude Allred Date: Tue, 10 Oct 2023 06:21:06 -0400 Subject: [PATCH] Add Husky to enforce pre-push yarn fmt-check (#50) * Add Husky to enforce pre-push yarn fmt-check * move husky to .config/.husky * Move husky from .husky to husky * hook test --- .config/husky/.husky/pre-push | 17 +++++++++++++++++ apps/sim-core/package.json | 2 ++ apps/sim-core/test.txt | 1 + apps/sim-core/yarn.lock | 5 +++++ 4 files changed, 25 insertions(+) create mode 100644 .config/husky/.husky/pre-push create mode 100644 apps/sim-core/test.txt diff --git a/.config/husky/.husky/pre-push b/.config/husky/.husky/pre-push new file mode 100644 index 0000000..e6fdbce --- /dev/null +++ b/.config/husky/.husky/pre-push @@ -0,0 +1,17 @@ +#!/usr/bin/env sh +. "$(dirname -- "$0")/_/husky.sh" + +echo "************************************************************************" +echo "** Running sim-core's 'yarn fmt-check' **" +echo "************************************************************************" + +cd apps/sim-core/ +yarn fmt-check + +if [ $? -ne 0 ]; then + echo "************************************************************************" + echo "** Formatting failed; Run 'yarn fmt' and commit before pushing. **" + echo "************************************************************************" + + exit 1 +fi \ No newline at end of file diff --git a/apps/sim-core/package.json b/apps/sim-core/package.json index 9840a3a..bcbb328 100644 --- a/apps/sim-core/package.json +++ b/apps/sim-core/package.json @@ -8,6 +8,7 @@ "// 02": "", "preinstall": "node scripts/preinstall.js", "postinstall": "yarn build:utils && yarn build:engine-web", + "prepare": "cd ../.. && husky install .config/husky", "all": "npx npm-run-all", "fmt:scripts": "prettier \"scripts/**/*.{ts,tsx,js,json}\" --write", "fmt-check:scripts": "prettier \"scripts/**/*.{ts,tsx,js,json}\" --check", @@ -110,6 +111,7 @@ "file-loader": "6.2.0", "fork-ts-checker-webpack-plugin": "6.0.3", "html-webpack-plugin": "4.5.1", + "husky": "^8.0.0", "identity-obj-proxy": "3.0.0", "jest": "26.6.3", "jest-canvas-mock": "2.3.0", diff --git a/apps/sim-core/test.txt b/apps/sim-core/test.txt new file mode 100644 index 0000000..911c7ef --- /dev/null +++ b/apps/sim-core/test.txt @@ -0,0 +1 @@ +test change diff --git a/apps/sim-core/yarn.lock b/apps/sim-core/yarn.lock index 094e247..6b6df08 100644 --- a/apps/sim-core/yarn.lock +++ b/apps/sim-core/yarn.lock @@ -9506,6 +9506,11 @@ human-signals@^1.1.1: resolved "https://registry.yarnpkg.com/human-signals/-/human-signals-1.1.1.tgz#c5b1cd14f50aeae09ab6c59fe63ba3395fe4dfa3" integrity sha512-SEQu7vl8KjNL2eoGBLF3+wAjpsNfA9XMlXAYj/3EdaNfAlxKthD1xjEQfGOUhllCGGJVNY34bRr6lPINhNjyZw== +husky@^8.0.0: + version "8.0.3" + resolved "https://registry.yarnpkg.com/husky/-/husky-8.0.3.tgz#4936d7212e46d1dea28fef29bb3a108872cd9184" + integrity sha512-+dQSyqPh4x1hlO1swXBiNb2HzTDN1I2IGLQx1GrBuiqFJfoMrnZWwVmatvSiO+Iz8fBUnf+lekwNo4c2LlXItg== + hyphenate-style-name@^1.0.3: version "1.0.4" resolved "https://registry.yarnpkg.com/hyphenate-style-name/-/hyphenate-style-name-1.0.4.tgz#691879af8e220aea5750e8827db4ef62a54e361d"