Sha256: 4f8928098d46903c717fa3fb04b6491fe2a47b58ffcf6d529d906da81353bc56

Contents?: true

Size: 988 Bytes

Versions: 12

Compression:

Stored size: 988 Bytes

Contents

# frozen_string_literal: true

desc "Run the prelaunch tasks"
task :prelaunch do
  def find_task(task_name)
    Pakyow.tasks.find { |task|
      task.name == task_name.to_s
    } || raise("#{Pakyow::Support::CLI.style.blue(task_name)} is not a prelaunch task")
  end

  def run_task(task_name, task_options)
    task_options[:env] = Pakyow.env
    task = find_task(task_name)

    Pakyow.logger.info "[prelaunch] running: #{task_name}, #{task_options}"
    task.call(task_options)
  end

  Pakyow.boot(unsafe: true)

  # Run prelaunch tasks registered with the environment.
  #
  Pakyow.config.tasks.prelaunch.each do |task_name, task_options = {}|
    run_task(task_name, task_options)
  end

  # Run prelaunch tasks registered with each pakyow app.
  #
  Pakyow.apps.each do |app|
    if app.is_a?(Pakyow::App)
      app.config.tasks.prelaunch.each do |task_name, task_options = {}|
        task_options[:app] = app
        run_task(task_name, task_options)
      end
    end
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
pakyow-core-1.0.6 lib/pakyow/tasks/prelaunch.rake
pakyow-core-1.0.5 lib/pakyow/tasks/prelaunch.rake
pakyow-core-1.0.4 lib/pakyow/tasks/prelaunch.rake
pakyow-core-1.0.3 lib/pakyow/tasks/prelaunch.rake
pakyow-core-1.0.2 lib/pakyow/tasks/prelaunch.rake
pakyow-core-1.0.1 lib/pakyow/tasks/prelaunch.rake
pakyow-core-1.0.0 lib/pakyow/tasks/prelaunch.rake
pakyow-core-1.0.0.rc5 lib/pakyow/tasks/prelaunch.rake
pakyow-core-1.0.0.rc4 lib/pakyow/tasks/prelaunch.rake
pakyow-core-1.0.0.rc3 lib/pakyow/tasks/prelaunch.rake
pakyow-core-1.0.0.rc2 lib/pakyow/tasks/prelaunch.rake
pakyow-core-1.0.0.rc1 lib/pakyow/tasks/prelaunch.rake