Created
February 27, 2018 23:02
-
-
Save leongaban/1cc5ab7c84013ab879b9dad028d21ead to your computer and use it in GitHub Desktop.
Script to limit your tests coverage check to specific directories
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
#!/usr/bin/env bash | |
JEST=node_modules/jest/bin/jest.js | |
HELP_TEXT="\n\n\tPass a target with '-t' or '--target'.\n" | |
RED='\033[0;31m' | |
NC='\033[0m' # No Color | |
POSITIONAL=() | |
while [[ $# -gt 0 ]] | |
do | |
key="$1" | |
case $key in | |
-t|--target) | |
TARGET="$2" | |
shift # past argument | |
shift # past value | |
;; | |
esac | |
done | |
set -- "${POSITIONAL[@]}" # restore positional parameters | |
if [ -z ${TARGET+x} ]; then | |
echo -e "${RED}Give me a target${NC}$HELP_TEXT" | |
exit 1 | |
fi | |
if [ -z ${TARGET} ]; then | |
echo -e "${RED}You gave me a flag... but no data?${NC}$HELP_TEXT" | |
exit 1 | |
fi | |
$JEST --coverage $TARGET | |
exit 0 | |
1 CommentCollapse |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment