2023-04-23 21:23:45 +05:30
|
|
|
#!/usr/bin/env ruby
|
|
|
|
# frozen_string_literal: true
|
2022-01-26 12:08:38 +05:30
|
|
|
|
2023-04-23 21:23:45 +05:30
|
|
|
require 'yaml'
|
2022-01-26 12:08:38 +05:30
|
|
|
|
2023-04-23 21:23:45 +05:30
|
|
|
rails_env = ENV.fetch('RAILS_ENV')
|
|
|
|
database_config = YAML.load_file(File.join(File.expand_path('..', __dir__), 'config', 'database.yml'))[rails_env]
|
2022-01-26 12:08:38 +05:30
|
|
|
|
2023-04-23 21:23:45 +05:30
|
|
|
task = ARGV.shift
|
|
|
|
raise ArgumentError, 'You need to pass a task name!' unless task
|
2022-01-26 12:08:38 +05:30
|
|
|
|
2023-04-23 21:23:45 +05:30
|
|
|
task = "#{task}:main" unless database_config.one?
|
|
|
|
cmd = ['bundle', 'exec', 'rake', task, *ARGV]
|
|
|
|
|
|
|
|
puts "Running: `#{cmd.join(' ')}`"
|
|
|
|
|
|
|
|
system(*cmd)
|