Added auto-beautifier
This commit is contained in:
parent
557d18dfc1
commit
50e53e6fe9
3 changed files with 29 additions and 0 deletions
12
hooks/pre-commit.sh
Executable file
12
hooks/pre-commit.sh
Executable file
|
@ -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
|
14
hooks/setup.sh
Executable file
14
hooks/setup.sh
Executable file
|
@ -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"
|
|
@ -43,5 +43,8 @@
|
||||||
"last 1 firefox version",
|
"last 1 firefox version",
|
||||||
"last 1 safari version"
|
"last 1 safari version"
|
||||||
]
|
]
|
||||||
|
},
|
||||||
|
"devDependencies": {
|
||||||
|
"prettier": "2.0.1"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue