Skip to content

Instantly share code, notes, and snippets.

@dmfilipenko
Last active June 3, 2016 13:21
Show Gist options
  • Select an option

  • Save dmfilipenko/91ef807ce78c46fe86fe673225fa55e9 to your computer and use it in GitHub Desktop.

Select an option

Save dmfilipenko/91ef807ce78c46fe86fe673225fa55e9 to your computer and use it in GitHub Desktop.

Revisions

  1. Dmitriy Filipenko revised this gist Jun 3, 2016. 1 changed file with 14 additions and 26 deletions.
    40 changes: 14 additions & 26 deletions Git hooks
    Original file line number Diff line number Diff line change
    @@ -1,38 +1,26 @@
    #!/bin/sh

    STAGED_FILES=$(git diff --name-only --diff-filter=ACM | grep ".jsx\{0,1\}$")
    echo $STAGED_FILES
    if [[ "$STAGED_FILES" = "" ]]; then
    exit 0
    fi

    PASS=true

    echo "\nElsint Javascript:\n"

    for FILE in $STAGED_FILES
    do
    ./node_modules/.bin/eslint $FILE
    if [[ "$?" == 0 ]]; then
    echo "\t\033[32mESLint Passed: $FILE\033[0m"
    else
    echo "\t\033[41mESLint Failed: $FILE\033[0m"
    PASS=false
    fi
    done
    npm run eslint
    if [[ "$?" == 0 ]]; then
    echo "\t\033[32mESLint Passed: $FILE\033[0m"
    else
    echo "\t\033[41mESLint Failed: $FILE\033[0m"
    PASS=false
    fi

    echo "\nElsint Javascript:\n"

    for FILE in $STAGED_FILES
    do
    npm run flow
    if [[ "$?" == 0 ]]; then
    echo "\t\033[32mFlow Passed\033[0m"
    else
    echo "\t\033[41mFlow Failed\033[0m"
    PASS=false
    fi
    done
    npm run flow
    if [[ "$?" == 0 ]]; then
    echo "\t\033[32mFlow Passed\033[0m"
    else
    echo "\t\033[41mFlow Failed\033[0m"
    PASS=false
    fi

    echo "\nJavascript validation completed!\n"

  2. Dmitriy Filipenko revised this gist May 31, 2016. 1 changed file with 45 additions and 10 deletions.
    55 changes: 45 additions & 10 deletions Git hooks
    Original file line number Diff line number Diff line change
    @@ -1,11 +1,46 @@
    #!/bin/sh
    SECONDS=0
    # do some work
    echo 'START: Flow check'
    npm run flow
    echo 'END: Flow check success'
    echo 'START: Eslint check'
    npm run eslint
    echo 'END: Eslint check success'
    duration=$SECONDS
    echo "$(($duration / 60)) minutes and $(($duration % 60)) seconds elapsed."

    STAGED_FILES=$(git diff --name-only --diff-filter=ACM | grep ".jsx\{0,1\}$")
    echo $STAGED_FILES
    if [[ "$STAGED_FILES" = "" ]]; then
    exit 0
    fi

    PASS=true

    echo "\nElsint Javascript:\n"

    for FILE in $STAGED_FILES
    do
    ./node_modules/.bin/eslint $FILE
    if [[ "$?" == 0 ]]; then
    echo "\t\033[32mESLint Passed: $FILE\033[0m"
    else
    echo "\t\033[41mESLint Failed: $FILE\033[0m"
    PASS=false
    fi
    done

    echo "\nElsint Javascript:\n"

    for FILE in $STAGED_FILES
    do
    npm run flow
    if [[ "$?" == 0 ]]; then
    echo "\t\033[32mFlow Passed\033[0m"
    else
    echo "\t\033[41mFlow Failed\033[0m"
    PASS=false
    fi
    done

    echo "\nJavascript validation completed!\n"

    if ! $PASS; then
    echo "\t\033[41mCOMMIT FAILED:\033[0m\n"
    exit 1
    else
    echo "\t\033[42mCOMMIT SUCCEEDED\033[0m\n"
    fi

    exit $?
  3. Dmitriy Filipenko revised this gist May 27, 2016. 1 changed file with 4 additions and 4 deletions.
    8 changes: 4 additions & 4 deletions Git hooks
    Original file line number Diff line number Diff line change
    @@ -1,11 +1,11 @@
    #!/bin/sh
    SECONDS=0
    # do some work
    echo 'RUN: Flow check'
    echo 'START: Flow check'
    npm run flow
    echo 'RUN: Flow check success'
    echo 'RUN: Eslint check'
    echo 'END: Flow check success'
    echo 'START: Eslint check'
    npm run eslint
    echo 'RUN: Eslint check success'
    echo 'END: Eslint check success'
    duration=$SECONDS
    echo "$(($duration / 60)) minutes and $(($duration % 60)) seconds elapsed."
  4. Dmitriy Filipenko revised this gist May 27, 2016. 1 changed file with 5 additions and 1 deletion.
    6 changes: 5 additions & 1 deletion Git hooks
    Original file line number Diff line number Diff line change
    @@ -1,7 +1,11 @@
    #!/bin/sh
    SECONDS=0
    # do some work
    echo 'RUN: Flow check'
    npm run flow
    echo 'RUN: Flow check success'
    echo 'RUN: Eslint check'
    npm run eslint
    echo 'RUN: Eslint check success'
    echo 'RUN: Eslint check success'
    duration=$SECONDS
    echo "$(($duration / 60)) minutes and $(($duration % 60)) seconds elapsed."
  5. Dmitriy Filipenko revised this gist May 27, 2016. 1 changed file with 6 additions and 2 deletions.
    8 changes: 6 additions & 2 deletions Git hooks
    Original file line number Diff line number Diff line change
    @@ -1,3 +1,7 @@
    #!/bin/sh

    npm run flow
    echo 'RUN: Flow check'
    npm run flow
    echo 'RUN: Flow check success'
    echo 'RUN: Eslint check'
    npm run eslint
    echo 'RUN: Eslint check success'
  6. Dmitriy Filipenko created this gist May 27, 2016.
    3 changes: 3 additions & 0 deletions Git hooks
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,3 @@
    #!/bin/sh

    npm run flow