-
-
Save betorobson/23e5914b51e844bac5eaa6032d6f3f88 to your computer and use it in GitHub Desktop.
Revisions
-
betorobson revised this gist
Oct 18, 2017 . 1 changed file with 2 additions and 2 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -4,15 +4,15 @@ ```bash $ mkdir hooks && curl -o hooks/post-merge -O https://gist.github.com/betorobson/23e5914b51e844bac5eaa6032d6f3f88/raw/e02ee803af1094a0dbff6c47febe02e1f5cb33b8/post-merge && curl -o hooks/post-checkout -O https://gist.github.com/betorobson/23e5914b51e844bac5eaa6032d6f3f88/raw/e02ee803af1094a0dbff6c47febe02e1f5cb33b8/post-checkout ``` ### 2. Add a script install at your package.json ```json ... "scripts": { "install": "cp ./hooks/* .git/hooks/ && chmod -R a+X .git/hooks/" }, ... ``` ### 3. Commit and push to remote repository #### At this point your team will get any change on package.json and bower.json files #### Thanks to these two guys: -
betorobson revised this gist
Oct 18, 2017 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -1,6 +1,6 @@ # Git hooks for NPM and Bower Projects ## 1. Copy theses files into your hooks folder ```bash $ mkdir hooks && curl -o hooks/post-merge -O https://gist.github.com/betorobson/23e5914b51e844bac5eaa6032d6f3f88/raw/e02ee803af1094a0dbff6c47febe02e1f5cb33b8/post-merge && curl -o hooks/post-checkout -O https://gist.github.com/betorobson/23e5914b51e844bac5eaa6032d6f3f88/raw/e02ee803af1094a0dbff6c47febe02e1f5cb33b8/post-checkout ``` -
betorobson revised this gist
Oct 18, 2017 . 2 changed files with 5 additions and 1 deletion.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -9,3 +9,5 @@ check_run() { check_run package.json "npm prune && npm install" check_run bower.json "bower prune && bower install" exit 0; 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 charactersOriginal file line number Diff line number Diff line change @@ -9,4 +9,6 @@ check_run() { } check_run package.json "npm prune && npm install" check_run bower.json "bower prune && bower install" exit 0; -
betorobson revised this gist
Feb 21, 2017 . 1 changed file with 2 additions and 2 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -12,8 +12,8 @@ $ mkdir hooks && curl -o hooks/post-merge -O https://gist.github.com/ }, ... ``` ###3. Commit and push to remote repository #### At this point your team will get any change on package.json and bower.json files #### Thanks to these two guys: - https://gist.github.com/sindresorhus/7996717 -
betorobson revised this gist
Feb 21, 2017 . 1 changed file with 3 additions and 7 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -1,14 +1,10 @@ # Git hooks for NPM and Bower Projects ##1. Copy theses files into your hooks folder ```bash $ mkdir hooks && curl -o hooks/post-merge -O https://gist.github.com/betorobson/23e5914b51e844bac5eaa6032d6f3f88/raw/e02ee803af1094a0dbff6c47febe02e1f5cb33b8/post-merge && curl -o hooks/post-checkout -O https://gist.github.com/betorobson/23e5914b51e844bac5eaa6032d6f3f88/raw/e02ee803af1094a0dbff6c47febe02e1f5cb33b8/post-checkout ``` ###2. Add a script install at your package.json ```json ... "scripts": { -
betorobson revised this gist
Feb 20, 2017 . No changes.There are no files selected for viewing
-
betorobson revised this gist
Feb 20, 2017 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -6,7 +6,7 @@ $ mkdir hooks ``` ##2. Copy theses files into your hooks folder ```bash $ curl -O https://gist.githubusercontent.com/betorobson/23e5914b51e844bac5eaa6032d6f3f88/raw/e02ee803af1094a0dbff6c47febe02e1f5cb33b8/post-merge && chmod +x post-merge && mv post-merge hooks/ && curl -O https://gist.githubusercontent.com/betorobson/23e5914b51e844bac5eaa6032d6f3f88/raw/e02ee803af1094a0dbff6c47febe02e1f5cb33b8/post-checkout && chmod +x post-checkout && mv post-checkout hooks/ ``` ###3. Add a script install at your package.json ```json -
betorobson revised this gist
Feb 20, 2017 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -17,7 +17,7 @@ $ curl -O https://gist.github.com/betorobson/23e5914b51e844bac5eaa6032d6f3f88/po ... ``` ### At this point your team will get any change on package.json and bower.json files #### Thanks to these two guys: - https://gist.github.com/sindresorhus/7996717 -
betorobson revised this gist
Feb 20, 2017 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -17,7 +17,7 @@ $ curl -O https://gist.github.com/betorobson/23e5914b51e844bac5eaa6032d6f3f88/po ... ``` ### At this point your team will get any change at package.json and bower.json files #### Thanks to these two guys: - https://gist.github.com/sindresorhus/7996717 -
betorobson revised this gist
Feb 20, 2017 . No changes.There are no files selected for viewing
-
betorobson revised this gist
Feb 20, 2017 . 1 changed file with 2 additions and 2 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -20,5 +20,5 @@ $ curl -O https://gist.github.com/betorobson/23e5914b51e844bac5eaa6032d6f3f88/po ### At this point your team will get any changes at package.json and bower.json files #### Thanks to these two guys: - https://gist.github.com/sindresorhus/7996717 - https://gist.github.com/jakemhiller/d342ad51505addf78ec628a16fd3280f -
betorobson revised this gist
Feb 20, 2017 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -19,6 +19,6 @@ $ curl -O https://gist.github.com/betorobson/23e5914b51e844bac5eaa6032d6f3f88/po ### At this point your team will get any changes at package.json and bower.json files #### Thanks to these two guys: https://gist.github.com/sindresorhus/7996717 https://gist.github.com/jakemhiller/d342ad51505addf78ec628a16fd3280f -
betorobson revised this gist
Feb 20, 2017 . 1 changed file with 2 additions and 2 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -20,5 +20,5 @@ $ curl -O https://gist.github.com/betorobson/23e5914b51e844bac5eaa6032d6f3f88/po ### At this point your team will get any changes at package.json and bower.json files Thanks to these two guys: https://gist.github.com/sindresorhus/7996717 https://gist.github.com/jakemhiller/d342ad51505addf78ec628a16fd3280f -
betorobson revised this gist
Feb 20, 2017 . 1 changed file with 5 additions and 1 deletion.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -17,4 +17,8 @@ $ curl -O https://gist.github.com/betorobson/23e5914b51e844bac5eaa6032d6f3f88/po ... ``` ### At this point your team will get any changes at package.json and bower.json files Thanks to these two guys: (https://gist.github.com/sindresorhus/7996717) (https://gist.github.com/jakemhiller/d342ad51505addf78ec628a16fd3280f) -
betorobson revised this gist
Feb 20, 2017 . 3 changed files with 8 additions and 12 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -1,10 +1,11 @@ #!/usr/bin/env bash # fork from https://gist.github.com/jakemhiller/d342ad51505addf78ec628a16fd3280f changed_files="$(git diff-tree -r --name-only --no-commit-id $1 $2)" check_run() { echo "$changed_files" | grep --quiet "$1" && eval "$2" } check_run package.json "npm prune && npm install" check_run bower.json "bower prune && bower install" 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 charactersOriginal file line number Diff line number Diff line change @@ -1,19 +1,12 @@ #!/usr/bin/env bash # MIT © Sindre Sorhus - sindresorhus.com # fork from https://gist.github.com/sindresorhus/7996717 changed_files="$(git diff-tree -r --name-only --no-commit-id ORIG_HEAD HEAD)" check_run() { echo "$changed_files" | grep --quiet "$1" && eval "$2" } check_run package.json "npm prune && npm install" check_run bower.json "bower prune && bower install" 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 charactersOriginal file line number Diff line number Diff line change @@ -15,4 +15,6 @@ $ curl -O https://gist.github.com/betorobson/23e5914b51e844bac5eaa6032d6f3f88/po "install": "cp ./hooks/* .git/hooks/ && chmod -R a+X .git/hooks/" }, ... ``` ### At this point your team will get any changes at package.json and bower.json files -
betorobson revised this gist
Feb 20, 2017 . 1 changed file with 6 additions and 32 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -1,36 +1,10 @@ #!/usr/bin/env bash changed_files="$(git diff-tree -r --name-only --no-commit-id $1 $2)" check_run() { echo "$changed_files" | grep --quiet "$1" && eval "$2" } check_run package.json "npm prune && npm install" check_run bower.json "bower prune && bower install" -
betorobson revised this gist
Feb 20, 2017 . 2 changed files with 41 additions and 1 deletion.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,36 @@ #!/bin/bash # Does not run if your local branch is behind the remote. # https://gist.github.com/stefansundin/82051ad2c8565999b914 # Exit early if this was only a file checkout, not a branch change ($3 == 1) [[ $3 == 0 ]] && exit 0 oldRef=$1 newRef=$2 # Exit early if the local branch is behind the remote LOCAL=$(git rev-parse @) REMOTE=$(git rev-parse @{u} 2> /dev/null) BASE=$(git merge-base @ @{u} 2> /dev/null) if [[ "$LOCAL" != "$REMOTE" && "$LOCAL" = "$BASE" ]]; then echo "You are behind origin, not running bundle/migrate post-checkout hook." exit 1 fi function changed { git diff --name-only $oldRef $newRef | grep "^$1" > /dev/null 2>&1 } if changed 'bower.json'; then echo "bower.json changed, installing" bower prune bower install fi if changed 'package.json'; then echo "Package.json changed, installing" npm prune npm install fi 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 charactersOriginal file line number Diff line number Diff line change @@ -11,5 +11,9 @@ check_run() { } # Example usage # In this example it's used to run `npm install` if package.json changed check_run package.json "npm prune && npm install" # In this example it's used to run `bower install` if bower.json changed check_run bower.json "bower prune && bower install" -
betorobson revised this gist
Feb 20, 2017 . 1 changed file with 12 additions and 0 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -3,4 +3,16 @@ ##1. Create a hooks folder ```bash $ mkdir hooks ``` ##2. Copy theses files into your hooks folder ```bash $ curl -O https://gist.github.com/betorobson/23e5914b51e844bac5eaa6032d6f3f88/post-merge && chmod +x post-merge && mv post-merge hooks/ && curl -O https://gist.github.com/betorobson/23e5914b51e844bac5eaa6032d6f3f88/post-checkout && chmod +x post-checkout && mv post-checkout hooks/ ``` ###3. Add a script install at your package.json ```json ... "scripts": { "install": "cp ./hooks/* .git/hooks/ && chmod -R a+X .git/hooks/" }, ... ``` -
betorobson revised this gist
Feb 20, 2017 . 1 changed file with 5 additions and 0 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -1 +1,6 @@ # Git hooks for NPM and Bower Projects ##1. Create a hooks folder ```bash $ mkdir hooks ``` -
betorobson revised this gist
Feb 20, 2017 . 1 changed file with 1 addition and 0 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1 @@ # Git hooks for NPM and Bower Projects -
betorobson renamed this gist
Feb 20, 2017 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. -
betorobson renamed this gist
Feb 20, 2017 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. -
sindresorhus revised this gist
Jul 16, 2016 . 1 changed file with 2 additions and 3 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -1,4 +1,4 @@ #!/usr/bin/env bash # MIT © Sindre Sorhus - sindresorhus.com # git hook to run a command after `git pull` if a specified file was changed @@ -11,6 +11,5 @@ check_run() { } # Example usage # In this example it's used to run `npm install` if package.json changed check_run package.json "npm install" -
sindresorhus created this gist
Dec 16, 2013 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,16 @@ #/usr/bin/env bash # MIT © Sindre Sorhus - sindresorhus.com # git hook to run a command after `git pull` if a specified file was changed # Run `chmod +x post-merge` to make it executable then put it into `.git/hooks/`. changed_files="$(git diff-tree -r --name-only --no-commit-id ORIG_HEAD HEAD)" check_run() { echo "$changed_files" | grep --quiet "$1" && eval "$2" } # Example usage # In this example it's used to run `npm install` if package.json changed and `bower install` if `bower.json` changed. check_run package.json "npm install" check_run bower.json "bower install"