diff --git a/hooks/pre-commit.sh b/hooks/pre-commit.sh new file mode 100755 index 0000000..2b233cc --- /dev/null +++ b/hooks/pre-commit.sh @@ -0,0 +1,12 @@ +#!/bin/sh + +FILES=$(git diff --cached --name-only --diff-filter=ACMR "*.js" "*.jsx" | sed 's| |\\ |g') +[ -z "$FILES" ] && exit 0 + +# Prettify all selected files +echo "$FILES" | xargs ./smart-hut/node_modules/.bin/prettier --write + +# Add back the modified/prettified files to staging +echo "$FILES" | xargs git add + +exit 0 diff --git a/hooks/setup.sh b/hooks/setup.sh new file mode 100755 index 0000000..31662da --- /dev/null +++ b/hooks/setup.sh @@ -0,0 +1,14 @@ +#!/bin/sh + +git config --unset core.hooksPath + +if [[ -z $(which realpath) ]]; then + this_dir="$(pwd)/hooks" +else + this_dir="$(dirname $(realpath "$0"))" +fi + +hook_script="$this_dir/pre-commit.sh" +ln -svf "$hook_script" "$this_dir/../.git/hooks/pre-commit" + +echo "Commit hook installed" diff --git a/smart-hut/icons.js b/smart-hut/icons.txt similarity index 100% rename from smart-hut/icons.js rename to smart-hut/icons.txt diff --git a/smart-hut/package.json b/smart-hut/package.json index 310d82f..19f6bcd 100644 --- a/smart-hut/package.json +++ b/smart-hut/package.json @@ -43,5 +43,8 @@ "last 1 firefox version", "last 1 safari version" ] + }, + "devDependencies": { + "prettier": "2.0.1" } } diff --git a/smart-hut/public/index.html b/smart-hut/public/index.html index 378b944..3c85f6b 100644 --- a/smart-hut/public/index.html +++ b/smart-hut/public/index.html @@ -1,21 +1,29 @@ - -
- - - - - - - - - - - -