Guest User

Untitled

a guest
Jul 25th, 2016
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.49 KB | None | 0 0
  1. #/usr/bin/env bash
  2. # MIT © Sindre Sorhus - sindresorhus.com
  3. # forked by Gianluca Guarini
  4.  
  5. changed_files="$(git diff-tree -r --name-only --no-commit-id ORIG_HEAD HEAD)"
  6.  
  7. check_run() {
  8. echo "$changed_files" | grep -E --quiet "$1" && eval "$2"
  9. }
  10.  
  11. # `npm install` and `npm prune` if the `package.json` file gets changed
  12. # to update all the nodejs ( grunt ) dependencies deleting the unused packages (not listed into the `package.json` file)
  13. check_run package.json "npm install && npm prune"
  14.  
  15. # `bower install` and `bower prune` if the `bower.json` file gets changed
  16. # to install all the frontend dependencies removing the unused packages ( not listed into the `bower.json` file )
  17. check_run bower.json "bower install && bower prune"
  18.  
  19. # `composer install` if the `composer.json` file gets changed
  20. # to update all the php dependencies
  21. check_run composer "sudo composer install"
  22.  
  23. # for the sass files we need a bit more
  24. if [ -f "config.rb" ]
  25. then
  26. # `compass compile` to compile all the scss files when they get changed
  27. check_run ".scss|.sass" "compass compile"
  28.  
  29. # check whether there is a gruntfile in the root of the project
  30. elif [[ -n $(find . -maxdepth 1 -iname "gruntfile.js" -o -iname "gruntfile.coffee") ]]
  31. then
  32. # try to compile just using grunt sass
  33. check_run ".scss|.sass" "grunt sass"
  34.  
  35. # check whether there is a gulpfile in the root of the project
  36. elif [[ -n $(find . -maxdepth 1 -iname "gulpfile.js" -iname "gulpfile.coffee") ]]
  37. then
  38. # try to compile just using grunt sass
  39. check_run ".scss|.sass" "gulp sass"
  40. fi
Add Comment
Please, Sign In to add comment