Class: Railbus::Generators::InstallGenerator

Inherits:
Rails::Generators::Base
  • Object
show all
Defined in:
lib/generators/railbus/install_generator.rb

Instance Method Summary collapse

Instance Method Details

#installObject



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/generators/railbus/install_generator.rb', line 8

def install
  # It's important to reset `Dir.pwd` because it's set to
  # parent dir of `Rails.root` while running `rails new` command.
  Dir.chdir(::Rails.root) do
    exit unless run 'yarn add @crosspath/yambus @crosspath/yambus-axios'
  end

  create_file('app/javascript/lib/routes.js.erb') do |f|
    <<-LINE
/* rails-erb-loader-dependencies ../config/routes */
<%= Railbus.generate %>
    LINE
  end

  puts 'Railbus installed!'
end