Is there some way to access a variable defined in a prerequisite? e.g.
task :new_file do
filename = 'foobar.txt' # in reality I ask the user for the filename
File.write(filename, 'Some glorious content')
end
task :new_file! => [:new_file] do
exec "vim #{filename.inspect}"
end
I'd like rake new_file!
to simply be a shorthand for rake new_file
along with launching vim for whatever file I created in the new_file
task.
All I can think of is populating a global variable FILENAME
in :new_file
and using it in new_file!
and then clearing it, but if there is a "more Rake" way to do it, I'd like to know.