moll / mina-rsync

Deploy with Rsync from any local (or remote) repository when using Mina.
Other
50 stars 25 forks source link

Not ignoring excluded files? #15

Open j6s opened 9 years ago

j6s commented 9 years ago

I am having a weird issue with mina-rsync:

As a part of my deployment I precompile some stuff via one of my gulp tasks. For that I need to install my node_modules.

Of course - I don't want the node_modules folder to be rsynced, so I added it as --excluded in :rsync_options. The problem is; The setting seems to be discarded. Any idea why that is?

mina deploy -v shows me the following (correct) rsync command, which seems to not be used, because it is correct and works as it should, when I run it on the command line:

rsync --exclude ".git*" --exclude "node_modules/" --exclude "settings.json" --exclude "typings" --recursive --delete --delete-excluded tmp/deploy/ remote@remote.com:~/path/to/project

Here are the important parts of my deploy.rb:

require 'rubygems'
require 'bundler/setup'
require 'mina/rsync'

# ...
set :repository, '.'
set :branch, 'master'
set :rsync_options, %w[
    --exclude ".git*" 
    --exclude "node_modules/" 
    --exclude "settings.json"  
    --exclude "typings"  
    --recursive  
    --delete  
    --delete-excluded
]

# ...

# precompile task
task :precompile do
  Dir.chdir settings.rsync_stage do

    puts "-----> removing old builds"
    system "rm", "-R", "js", "htdocs/dist"

    puts "-----> Installing modules"
    # npm install is here
    system "npm", "install", "--quiet";
    system "bundle", "install";

    puts "-----> installing typescript definitions"
    system "tsd", "reinstall";

    puts "-----> running gulp build"
    system "gulp", "build";

    def checkfile(file)
      if not File.exists?(file)
        throw "file " + file + " does not exist"
      else
        puts "Compiled file exists: " + file;
      end
    end;

    puts "-----> checking if compiled files exist"
    checkfile("htdocs/dist/main.css")
    checkfile("htdocs/dist/scripts.js")
    checkfile("htdocs/dist/scripts.min.js")
  end;
end;

task "rsync:stage" do
  invoke :precompile;
end;

desc "Deploys the current version to the server."
task :deploy => :environment do
  deploy do
    # Put things that will set up an empty directory into a fully set-up
    # instance of your project.
    invoke "rsync:deploy"
    invoke "deploy:cleanup"
    queue "npm install --production --quiet"
    queue "cd htdocs && bower install"

    to :launch do
      queue "forever stopall"
      queue "forever start #{deploy_to}/#{current_path}/js/index.js"
    end
  end
end