Sha256: d092a283cf810d0e2d3e3c771b3fb386d9535717adf970e01af99d14c536cde4

Contents?: true

Size: 1.28 KB

Versions: 2

Compression:

Stored size: 1.28 KB

Contents

# frozen_string_literal: true

namespace :frontend do
  desc "Run frontend bundler independently"
  task :watcher, :sidecar do |_task, args|
    # sidecar is when the task is running alongside the start command
    sidecar = args[:sidecar] == true
    Bridgetown::Utils::Aux.group do
      run_process "Frontend", :yellow, "bundle exec bridgetown frontend:dev"
    end
    if sidecar
      sleep 4 # give Webpack time to boot before returning control to the start command
    else
      trap("INT") do
        Bridgetown::Utils::Aux.kill_processes
        sleep 0.5
        exit(0)
      end
      loop { sleep 1000 }
    end
  end
end

desc "Prerequisite task which loads site and provides automation"
task :environment do
  class HammerActions < Thor # rubocop:disable Lint/ConstantDefinitionInBlock
    include Thor::Actions
    include Bridgetown::Commands::Actions

    def self.source_root
      Dir.pwd
    end

    def self.exit_on_failure?
      true
    end

    private

    def site
      @site ||= Bridgetown::Site.new(Bridgetown.configuration)
    end
  end

  define_singleton_method :automation do |*args, &block|
    @hammer ||= HammerActions.new
    @hammer.instance_exec(*args, &block)
  end

  define_singleton_method :site do
    @hammer ||= HammerActions.new
    @hammer.send(:site)
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
bridgetown-core-1.0.0.alpha3 lib/bridgetown-core/tasks/bridgetown_tasks.rake
bridgetown-core-1.0.0.alpha2 lib/bridgetown-core/tasks/bridgetown_tasks.rake