Skip to content

Commit

Permalink
CI: Tests failed with undefined Rake
Browse files Browse the repository at this point in the history
  • Loading branch information
olleolleolle committed Aug 2, 2024
1 parent 8e5fc7f commit bc7e36d
Showing 1 changed file with 24 additions and 22 deletions.
46 changes: 24 additions & 22 deletions lib/railsless_rake_task_runner.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,35 +10,37 @@ def self.load_rails
end
end

# Try to run no-rails tasks first. Fallback to rails if none is found.
Rake.application.instance_eval do
module Rake
class Task
alias :old_lookup_prerequisite :lookup_prerequisite
if defined?(Rake)
# Try to run no-rails tasks first. Fallback to rails if none is found.
Rake.application.instance_eval do
module Rake
class Task
alias :old_lookup_prerequisite :lookup_prerequisite

def lookup_prerequisite(prerequisite_name)
if prerequisite_name == "environment" && !Rake.application.lookup(prerequisite_name)
RailslessRakeTaskRunner.load_rails
def lookup_prerequisite(prerequisite_name)
if prerequisite_name == "environment" && !Rake.application.lookup(prerequisite_name)
RailslessRakeTaskRunner.load_rails
end
old_lookup_prerequisite(prerequisite_name)
end
old_lookup_prerequisite(prerequisite_name)
end
end
end

def top_level
if running_a_task? && requested_tasks_exist?
super
else
RailslessRakeTaskRunner.load_rails
super
def top_level
if running_a_task? && requested_tasks_exist?
super
else
RailslessRakeTaskRunner.load_rails
super
end
end
end

def running_a_task?
!(options.show_tasks || options.show_prereqs)
end
def running_a_task?
!(options.show_tasks || options.show_prereqs)
end

def requested_tasks_exist?
top_level_tasks.any? { |task| lookup(task) }
def requested_tasks_exist?
top_level_tasks.any? { |task| lookup(task) }
end
end
end

0 comments on commit bc7e36d

Please sign in to comment.