Commit 432afa2c authored by Julian Aron Prenner's avatar Julian Aron Prenner

Properly implement directory tasks

parent dc39d229
...@@ -237,7 +237,8 @@ module MiniRake ...@@ -237,7 +237,8 @@ module MiniRake
# Time stamp for file task. # Time stamp for file task.
def timestamp def timestamp
File::stat(name.to_s).mtime stat = File::stat(name.to_s)
stat.directory? ? Time.at(0) : stat.mtime
end end
end end
...@@ -254,12 +255,14 @@ module MiniRake ...@@ -254,12 +255,14 @@ module MiniRake
# Declare a set of files tasks to create the given directories on # Declare a set of files tasks to create the given directories on
# demand. # demand.
def directory(dir) def directory(args, &block)
path = [] MiniRake::FileTask.define_task(args) do |t|
Sys.split_all(dir).each do |p| block.call(t) unless block.nil?
path << p dir = args.is_a?(Hash) ? args.keys.first : args
FileTask.define_task(File.join(path)) do |t| dir.split(File::SEPARATOR).reject(&:empty?).inject("") do |acc, part|
Sys.makedirs(t.name) (acc + File::SEPARATOR + part).tap do |d|
Dir.mkdir(d) unless File.exists? d
end
end end
end end
end end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment