Created
July 12, 2019 14:49
-
-
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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