summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorJulian Aron Prenner <[email protected]>2015-01-06 21:23:19 +0100
committerJulian Aron Prenner <[email protected]>2015-01-06 21:23:19 +0100
commit432afa2c42f82093626f88242073ce135ad1b156 (patch)
tree346f8b3453f3950b73f6176497cda616471a19d9
parentdc39d2290a4c7b5d75abbb85426cb486bc4c9bfd (diff)
downloadmruby-432afa2c42f82093626f88242073ce135ad1b156.tar.gz
mruby-432afa2c42f82093626f88242073ce135ad1b156.zip
Properly implement directory tasks
-rwxr-xr-xminirake17
1 files changed, 10 insertions, 7 deletions
diff --git a/minirake b/minirake
index bdaef0b87..6b23e8c7d 100755
--- a/minirake
+++ b/minirake
@@ -237,7 +237,8 @@ module MiniRake
# Time stamp for file task.
def timestamp
- File::stat(name.to_s).mtime
+ stat = File::stat(name.to_s)
+ stat.directory? ? Time.at(0) : stat.mtime
end
end
@@ -254,12 +255,14 @@ module MiniRake
# Declare a set of files tasks to create the given directories on
# demand.
- def directory(dir)
- path = []
- Sys.split_all(dir).each do |p|
- path << p
- FileTask.define_task(File.join(path)) do |t|
- Sys.makedirs(t.name)
+ def directory(args, &block)
+ MiniRake::FileTask.define_task(args) do |t|
+ block.call(t) unless block.nil?
+ dir = args.is_a?(Hash) ? args.keys.first : args
+ dir.split(File::SEPARATOR).reject(&:empty?).inject("") do |acc, part|
+ (acc + File::SEPARATOR + part).tap do |d|
+ Dir.mkdir(d) unless File.exists? d
+ end
end
end
end