- 
      
- 
        Save guilleiguaran/1250021 to your computer and use it in GitHub Desktop. 
    Compile assets and push them automatically when run rake assets:precompile
  
        
  
    
      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
    
  
  
    
  | class AssetsCompiler < Sprockets::StaticCompiler | |
| def precompile(paths) | |
| ensure_clean_git | |
| Rake::Task["assets:clean"].invoke | |
| super | |
| commit_compiled_assets | |
| push | |
| end | |
| def ensure_clean_git | |
| raise "Can't deploy without a clean git status." if git_dirty? | |
| end | |
| def commit_compiled_assets | |
| run "git add -u && git add . && git commit -am 'Compiled assets'" | |
| end | |
| def push | |
| run "git push" | |
| end | |
| private | |
| def run(command) | |
| puts "+ Running: #{command}" | |
| puts "-- #{system command}" | |
| end | |
| def git_dirty? | |
| `[[ $(git diff --shortstat 2> /dev/null | tail -n1) != "" ]]` | |
| dirty = $?.success? | |
| end | |
| end | |
| Rails.application.config.assets.compiler = AssetsCompiler | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment