Skip to content

Instantly share code, notes, and snippets.

@danielwaltz
Created July 12, 2019 14:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save danielwaltz/878e4ea79ba178a170c9c9e02adf0ccb to your computer and use it in GitHub Desktop.
Save danielwaltz/878e4ea79ba178a170c9c9e02adf0ccb to your computer and use it in GitHub Desktop.
Quick and easy alias to run prettier on all files in a directory
prettyall() {
DIR="${1:-.}"
EXCLUDE_DIRS="node_modules,vendor,build,dist,coverage"
# Prefer using local prettier bin if available
if [ -f ./node_modules/.bin/prettier ]; then
PRETTIER_BIN="./node_modules/.bin/prettier"
else
PRETTIER_BIN="prettier"
fi
$PRETTIER_BIN --write "$DIR/**/*.{js,jsx,ts,css,scss,sass,html,vue,graphql,gql,json,md,yaml}" "!$DIR/{$EXCLUDE_DIRS}/**/*"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment