Sha256: af4d94dfa20426f5e899e3b5942a77cfbbed02de7c12eb01712ab48266cb684f

Contents?: true

Size: 772 Bytes

Versions: 1

Compression:

Stored size: 772 Bytes

Contents

# frozen_string_literal: true
require "rails/generators"

module P2pStreamsChannel
  class InstallGenerator < ::Rails::Generators::Base
    source_root File.expand_path("../templates", __FILE__)
    
    def importmap
      return unless (importmap_path = Rails.root.join("config/importmap.rb")).exist?
      
      append_to_file importmap_path, %(\npin_all_from "#{File.expand_path("../../../../app/assets/javascripts/p2p/", __dir__)}", under: "p2p"\n)
    end

    def node
      return unless Rails.root.join("package.json").exist?

      run "yarn add p2p@file:#{File.expand_path("../../../../app/assets/javascripts/p2p/", __dir__)}"
    end

    def create_initializer
      copy_file "initializer.rb", "config/initializers/p2p_streams_channel.rb"
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
p2p_streams_channel-0.0.2 lib/rails/generators/p2p_streams_channel/install_generator.rb