summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorJacob Schatz <jschatz1@gmail.com>2017-12-20 12:09:22 -0500
committerJacob Schatz <jschatz1@gmail.com>2017-12-20 12:09:22 -0500
commit1d7875386059cb880e8ea8766359e87c42ff8ec6 (patch)
treecd89a26c65a0811373e34483ff87aa0c8234eb17 /scripts
parentf5290c9738bbca7b130ddc86c0cdcc3f35e34c3a (diff)
downloadgitlab-ce-1d7875386059cb880e8ea8766359e87c42ff8ec6.tar.gz
Initial install
Diffstat (limited to 'scripts')
-rw-r--r--scripts/pre-commit11
1 files changed, 11 insertions, 0 deletions
diff --git a/scripts/pre-commit b/scripts/pre-commit
new file mode 100644
index 00000000000..e3ff5927922
--- /dev/null
+++ b/scripts/pre-commit
@@ -0,0 +1,11 @@
+#!/bin/sh
+jsfiles=$(git diff --cached --name-only --diff-filter=ACM "*.js" "*.jsx" | tr '\n' ' ')
+[ -z "$jsfiles" ] && exit 0
+
+# Prettify all staged .js files
+echo "$jsfiles" | xargs ./node_modules/.bin/prettier --write
+
+# Add back the modified/prettified files to staging
+echo "$jsfiles" | xargs git add
+
+exit 0 \ No newline at end of file