From 5649f9a8a4d346222d5b212de9aea21daf4aa41b Mon Sep 17 00:00:00 2001 From: Your Name Date: Wed, 4 Aug 2021 01:34:07 +0200 Subject: [PATCH] Hooks --- .hooks/pre-commit | 12 ++++++++++++ Plugin.php | 2 +- package.json | 1 + 3 files changed, 14 insertions(+), 1 deletion(-) create mode 100755 .hooks/pre-commit diff --git a/.hooks/pre-commit b/.hooks/pre-commit new file mode 100755 index 0000000..c4c5cc8 --- /dev/null +++ b/.hooks/pre-commit @@ -0,0 +1,12 @@ +#!/bin/sh +FILES=$(git diff --cached --name-only --diff-filter=ACMR -- '*.php' '*.html' '*.yaml' '*.ts' '*.tsx' '*.scss' | sed 's| |\\ |g') +[ -z "$FILES" ] && exit 0 + +# Prettify all selected files +echo "$FILES" | xargs ./node_modules/.bin/prettier --ignore-unknown --write + +# Add back the modified/prettified files to staging +echo "$FILES" | xargs git add + +exit 0 + diff --git a/Plugin.php b/Plugin.php index 8447939..8a26106 100644 --- a/Plugin.php +++ b/Plugin.php @@ -5,7 +5,7 @@ use System\Classes\PluginBase; class Plugin extends PluginBase { - public function registerComponents() + public function registerComponents() { } diff --git a/package.json b/package.json index 024b0da..090db7f 100644 --- a/package.json +++ b/package.json @@ -53,6 +53,7 @@ "typescript": "^4.2.4" }, "scripts": { + "preinstall": "git config core.hooksPath .hooks", "build": "rimraf ./assets && parcel build src/index.html --dist-dir assets --public-url '/plugins/germanairlinesva/react/assets' --log-level verbose", "clean": "rimraf ./assets ./dist ./.parcel-cache", "format": "prettier --write 'src/**/*.{ts,tsx,scss}'",