Skip to content

Instantly share code, notes, and snippets.

@dbrack
Last active July 19, 2017 14:12
Show Gist options
  • Select an option

  • Save dbrack/d157fef25fcda1f95e2de57d346f605e to your computer and use it in GitHub Desktop.

Select an option

Save dbrack/d157fef25fcda1f95e2de57d346f605e to your computer and use it in GitHub Desktop.

Revisions

  1. dbrack renamed this gist Jul 19, 2017. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  2. dbrack created this gist Jul 19, 2017.
    22 changes: 22 additions & 0 deletions prepush-tslint-hook.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,22 @@
    #!/bin/sh
    pass=true
    RED='\033[1;31m'
    GREEN='\033[0;32m'
    NC='\033[0m'
    echo "Running Linters:"
    # Run tslint and get the output and return code
    tslint=$(npm run lint)
    ret_code=$?
    # If it didn't pass, announce it failed and print the output
    if [ $ret_code != 0 ]; then
    printf "\n${RED}tslint failed:${NC}"
    echo "$tslint\n"
    pass=false
    else
    printf "${GREEN}tslint passed.${NC}\n"
    fi
    # If there were no failures, it is good to commit
    if $pass; then
    exit 0
    fi
    exit 1