Request: An alternate FileTask that checks whether the file was made
Nobody has claimed this yet.
- Dominant language
- Ruby
- Stars
- 2.5k
- Forks
- 650
- Avg merge
- 6m
- Merged PRs (30d)
- 3
Description
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
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reading the existing Rake::FileTask behavior and the Rake::DSL task definitions referenced in the issue. Verify how a task action runs when no exceptions occur, then confirm the new task type should fail when its named file is still absent, using the provided required_file example as the completion check.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- ruby
- Domain
- build-system
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100