Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Request: An alternate FileTask that checks whether the file was made #342

Open
bmundt6 opened this issue Mar 11, 2020 · 0 comments
Open

Comments

@bmundt6
Copy link

bmundt6 commented Mar 11, 2020

I think the current implementation of the file task makes perfect sense: just trigger a series of actions based on a file's status, in case you don't necessarily want to actually produce that file.

However, in cases where you do want to produce that file, it would be nice to have a separate task type that supports that, i.e. fails if the task actions don't produce the file even when there are no exceptions thrown.

Example:

class Rake::RequiredFileTask < Rake::FileTask                  
  def execute(*args)                                          
    super(*args)                                              
    File.exists?(name) or raise "File #{name} was not created successfully"
  end                                                                      
end                                                                        

module Rake::DSL
  def required_file(*args, &block) # :doc:
    Rake::RequiredFileTask.define_task(*args, &block)
  end                                                
end

Then, if invoked as:

required_file 'a.out' do |t|
  # do nothing
end

an error would be thrown:

rake aborted!
File a.out was not created successfully
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

1 participant