File: git-pre-commit

package info (click to toggle)
node-to-regex 3.0.2%2B~cs6.3.28-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 1,252 kB
  • sloc: javascript: 10,225; sh: 10; makefile: 7
file content (20 lines) | stat: -rwxr-xr-x 369 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#!/bin/sh

# Prettier

jsfiles=$(git diff HEAD --name-only --diff-filter=ACM "*.js" | tr '\n' ' ')

if [ ! -z "$jsfiles" ]
then
  # 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
fi

# Pre-commit validaitons:

npm test

npm run eslint