Class: Hauler::Generators::InstallGenerator
- Inherits:
-
Rails::Generators::Base
- Object
- Rails::Generators::Base
- Hauler::Generators::InstallGenerator
- Defined in:
- lib/generators/hauler/install_generator.rb
Overview
:nodoc:
Instance Method Summary collapse
- #add_node_modules_to_gitignore ⇒ Object
- #copy_eslintrc ⇒ Object
- #copy_example_assets ⇒ Object
- #copy_hauler_config ⇒ Object
- #copy_hauler_initializer ⇒ Object
- #copy_package_json ⇒ Object
- #copy_sass_lint_yml ⇒ Object
- #copy_webpack_config ⇒ Object
- #install_npm ⇒ Object
Instance Method Details
#add_node_modules_to_gitignore ⇒ Object
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_eslintrc ⇒ Object
21 22 23 |
# File 'lib/generators/hauler/install_generator.rb', line 21 def copy_eslintrc template 'eslintrc.json', '.eslintrc.json' end |
#copy_example_assets ⇒ Object
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_config ⇒ Object
12 13 14 |
# File 'lib/generators/hauler/install_generator.rb', line 12 def copy_hauler_config template 'config/hauler.js' end |
#copy_hauler_initializer ⇒ Object
8 9 10 |
# File 'lib/generators/hauler/install_generator.rb', line 8 def copy_hauler_initializer template 'config/initializers/hauler.rb' end |
#copy_package_json ⇒ Object
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_yml ⇒ Object
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_config ⇒ Object
44 45 46 |
# File 'lib/generators/hauler/install_generator.rb', line 44 def copy_webpack_config template 'webpack.config.js' end |
#install_npm ⇒ Object
48 49 50 |
# File 'lib/generators/hauler/install_generator.rb', line 48 def install_npm generate 'hauler:install_npm' end |