From 375750ca0ad3983f5998290d217a1d36458ab2fe Mon Sep 17 00:00:00 2001 From: Dustin Rue Date: Tue, 22 Mar 2022 14:24:57 -0500 Subject: [PATCH 1/4] allow husky to install properly regardless of where wp-scaffold is used --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 3ca1fc56..eb9f1a42 100755 --- a/package.json +++ b/package.json @@ -12,7 +12,7 @@ "mu-plugins/10up-plugin" ], "scripts": { - "prepare": "husky install", + "prepare": "TEN=$(pwd); UP=$(git rev-parse --show-toplevel); TENUP=\"${TEN#\"$UP\"}\"; cd $(git rev-parse --show-toplevel); husky install .${TENUP}/.husky", "build": "npm run build --workspaces --if-present", "start": "npm run watch", "watch:theme": "npm run watch -w=tenup-theme", From e35f9debe4a0535c8fae62a8bc2261530ff1bb39 Mon Sep 17 00:00:00 2001 From: Dustin Rue Date: Tue, 22 Mar 2022 14:49:20 -0500 Subject: [PATCH 2/4] adjust the pre-commit script so it can find it's files --- .husky/pre-commit | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/.husky/pre-commit b/.husky/pre-commit index 36af2198..3c817128 100755 --- a/.husky/pre-commit +++ b/.husky/pre-commit @@ -1,4 +1,11 @@ -#!/bin/sh +#!/bin/bash . "$(dirname "$0")/_/husky.sh" +PARENT_DIR=$(git rev-parse --show-toplevel) +SCAFFOLD_PATH=$(grep hooksPath ${PARENT_DIR}/.git/config | awk '{print $3}') + +if [ ! -z "${SCAFFOLD_PATH}" ]; then + cd ${PARENT_DIR}/${SCAFFOLD_PATH}/.. +fi + npx lint-staged From 8cc5d37ce9f5922c65386b17dff577b5bdfba17e Mon Sep 17 00:00:00 2001 From: Dustin Rue Date: Thu, 13 Apr 2023 09:43:54 -0500 Subject: [PATCH 3/4] Update package.json allow for spaces in the path --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index eb9f1a42..293a3dad 100755 --- a/package.json +++ b/package.json @@ -12,7 +12,7 @@ "mu-plugins/10up-plugin" ], "scripts": { - "prepare": "TEN=$(pwd); UP=$(git rev-parse --show-toplevel); TENUP=\"${TEN#\"$UP\"}\"; cd $(git rev-parse --show-toplevel); husky install .${TENUP}/.husky", + "prepare": "TEN=\"$(pwd)\"; UP=\"$(git rev-parse --show-toplevel)\"; TENUP=\"${TEN#\"$UP\"}\"; cd \"$(git rev-parse --show-toplevel)\"; husky install .\"${TENUP}\"/.husky", "build": "npm run build --workspaces --if-present", "start": "npm run watch", "watch:theme": "npm run watch -w=tenup-theme", From 3770319de98a8d72eb777f2d5c9a9782e7330597 Mon Sep 17 00:00:00 2001 From: Dustin Rue Date: Thu, 13 Apr 2023 09:46:40 -0500 Subject: [PATCH 4/4] Update pre-commit also allow for spaces in the path in the pre-commit hook --- .husky/pre-commit | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/.husky/pre-commit b/.husky/pre-commit index 3c817128..b6770433 100755 --- a/.husky/pre-commit +++ b/.husky/pre-commit @@ -1,11 +1,10 @@ #!/bin/bash . "$(dirname "$0")/_/husky.sh" -PARENT_DIR=$(git rev-parse --show-toplevel) -SCAFFOLD_PATH=$(grep hooksPath ${PARENT_DIR}/.git/config | awk '{print $3}') +PARENT_DIR="$(git rev-parse --show-toplevel)" +SCAFFOLD_PATH=$(grep hooksPath "${PARENT_DIR}"/.git/config | awk '{print $3}') if [ ! -z "${SCAFFOLD_PATH}" ]; then - cd ${PARENT_DIR}/${SCAFFOLD_PATH}/.. + cd "${PARENT_DIR}/${SCAFFOLD_PATH}/.." fi - npx lint-staged