Declare a set of files tasks to create the given directories on demand.
# File minirake, line 302
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) + ['']).inject do |acc, part|
(acc + File::SEPARATOR).tap do |d|
Dir.mkdir(d) unless File.exists? d
end + part
end
end
end
Declare a file task.
# File minirake, line 296
def file(args, &block)
MiniRake::FileTask.define_task(args, &block)
end
Write a message to standard out if $verbose is enabled.
# File minirake, line 320
def log(msg)
print " " if $trace && $verbose
puts msg if $verbose
end
Declare a rule for auto-tasks.
# File minirake, line 315
def rule(args, &block)
MiniRake::Task.create_rule(args, &block)
end
Run the system command cmd.
# File minirake, line 326
def sh(cmd)
puts cmd if $verbose
if !$rake_root_fiber || Fiber.current == $rake_root_fiber
system(cmd) or fail "Command Failed: [#{cmd}]"
return
end
pid = Process.spawn(cmd)
$rake_fiber_table[pid] = {
fiber: Fiber.current,
command: cmd,
process_waiter: Process.detach(pid)
}
$rake_root_fiber.transfer
end