Class: Hauler::Generators::InstallGenerator

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

Overview

:nodoc:

Instance Method Summary collapse

Instance Method Details

#add_node_modules_to_gitignoreObject



34
35
36
37
38
39
40
41
42
# File 'lib/generators/hauler/install_generator.rb', line 34

def add_node_modules_to_gitignore
  has_gitignore = File.exist?(Rails.root.join('package.json'))
  return if !has_gitignore

  has_node_modules = IO.read('.gitignore').include? 'node_modules'
  return if has_node_modules

  inject_into_file '.gitignore', "/node_modules\n", before: /\Z/m
end

#copy_eslintrcObject



21
22
23
# File 'lib/generators/hauler/install_generator.rb', line 21

def copy_eslintrc
  template 'eslintrc.json', '.eslintrc.json'
end

#copy_example_assetsObject



16
17
18
19
# File 'lib/generators/hauler/install_generator.rb', line 16

def copy_example_assets
  has_file = File.exist?(Rails.root.join('app', 'assets', 'index.js'))
  template 'app/assets/index.js' if !has_file
end

#copy_hauler_configObject



12
13
14
# File 'lib/generators/hauler/install_generator.rb', line 12

def copy_hauler_config
  template 'config/hauler.js'
end

#copy_hauler_initializerObject



8
9
10
# File 'lib/generators/hauler/install_generator.rb', line 8

def copy_hauler_initializer
  template 'config/initializers/hauler.rb'
end

#copy_package_jsonObject



29
30
31
32
# File 'lib/generators/hauler/install_generator.rb', line 29

def copy_package_json
  has_package_json = File.exist?(Rails.root.join('package.json'))
  template 'package.json' if !has_package_json
end

#copy_sass_lint_ymlObject



25
26
27
# File 'lib/generators/hauler/install_generator.rb', line 25

def copy_sass_lint_yml
  template 'sass-lint.yml', '.sass-lint.yml'
end

#copy_webpack_configObject



44
45
46
# File 'lib/generators/hauler/install_generator.rb', line 44

def copy_webpack_config
  template 'webpack.config.js'
end

#install_npmObject



48
49
50
# File 'lib/generators/hauler/install_generator.rb', line 48

def install_npm
  generate 'hauler:install_npm'
end