Skip to content

Instantly share code, notes, and snippets.

@mikeobrien
Created August 1, 2010 18:08
Show Gist options
  • Save mikeobrien/503592 to your computer and use it in GitHub Desktop.
Save mikeobrien/503592 to your computer and use it in GitHub Desktop.
# robocopy.rb
class Robocopy
attr_accessor :source, :target, :excludeDirs, :includeFiles, :logPath
def run()
robocopy = "robocopy.exe " \
"\"#{@source}\" " \
"\"#{@target}\" " \
"/MIR " \
"/XD #{@excludeDirs} " \
"/IF #{@includeFiles} " \
"/LOG+:\"#{@logPath}\" " \
"/TEE"
errorHandler = \
lambda do |ok, res|
raise "Robocopy failed with exit " \
"code #{res.exitstatus}." \
if res.exitstatus > 8
end
sh robocopy, &errorHandler
end
end
def robocopy(*args, &block)
body = lambda { |*args|
rc = Robocopy.new
block.call(rc)
rc.run
}
Rake::Task.define_task(*args, &body)
end
# rakefile.rb
desc "Deploys the application."
robocopy :deploy => :build do |rc|
rc.source = "src/ProjectEuler.UI"
rc.target = "D:/Websites/euler.mikeobrien.net/wwwroot"
rc.excludeDirs = "obj"
rc.includeFiles = "*.dll *.pdb *.config *.asax *.ascx *.ashx " \
"*.aspx *.master *.htm *.html *.txt *.css " \
"*.gif *.jpg *.jpeg *.png *.xml *.js"
rc.logPath = "Robocopy.log"
end
@mikeobrien
Copy link
Author

Nice catch, thx for pointing that out.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment