Class: AbleGitHooks::Generators::InstallGenerator

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

Instance Method Summary collapse

Instance Method Details

#copy_eslint_defaultsObject



34
35
36
# File 'lib/able_git_hooks/generators/install_generator.rb', line 34

def copy_eslint_defaults
  copy_file "eslintrc.json", ".eslintrc.json"
end

#copy_prettier_defaultsObject



38
39
40
# File 'lib/able_git_hooks/generators/install_generator.rb', line 38

def copy_prettier_defaults
  copy_file "prettierrc", ".prettierrc"
end

#copy_rubocop_defaultsObject



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

def copy_rubocop_defaults
  template "rubocop.yml", "config/rubocop.yml"
end

#copy_stylelint_defaultsObject



49
50
51
52
53
# File 'lib/able_git_hooks/generators/install_generator.rb', line 49

def copy_stylelint_defaults
  if options["with_stylelint"]
    copy_file "stylelintrc", ".stylelintrc"
  end
end

#install_eslint_hooksObject



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

def install_eslint_hooks
  copy_file "eslint-check.js", "hooks/pre-commit/eslint-check.js"
  chmod "hooks/pre-commit/eslint-check.js", 0755
end

#install_git_hooksObject



10
11
12
13
14
15
16
17
18
# File 'lib/able_git_hooks/generators/install_generator.rb', line 10

def install_git_hooks
  copy_file "_do_hook", ".git/hooks/_do_hook"
  chmod ".git/hooks/_do_hook", 0755

  AbleGitHooks::SCRIPTS.each do |hook|
    create_link ".git/hooks/#{hook}", "_do_hook"
    chmod       ".git/hooks/#{hook}", 0755
  end
end

#install_rubocop_hooksObject



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

def install_rubocop_hooks
  copy_file "rubocop.rb", "hooks/pre-commit/rubocop.rb"
  chmod "hooks/pre-commit/rubocop.rb", 0755
end

#install_stylelint_hooksObject



42
43
44
45
46
47
# File 'lib/able_git_hooks/generators/install_generator.rb', line 42

def install_stylelint_hooks
  if options["with_stylelint"]
    copy_file "stylelint-check.js", "hooks/pre-commit/stylelint-check.js"
    chmod "hooks/pre-commit/stylelint-check.js", 0755
  end
end