Created
August 1, 2010 18:08
-
-
Save mikeobrien/503592 to your computer and use it in GitHub Desktop.
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
# 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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Nice catch, thx for pointing that out.