Class: Terraspace::CLI::New::GitHook

Inherits:
Thor::Group
  • Object
show all
Includes:
Thor::Actions
Defined in:
lib/terraspace/cli/new/git_hook.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.cli_optionsObject



5
6
7
8
9
10
# File 'lib/terraspace/cli/new/git_hook.rb', line 5

def self.cli_options
  [
    [:envs, type: :array, default: %w[dev prod], desc: "envs to build"],
    [:type, aliases: %w[t], default: "pre-push", desc: "git hook type"],
  ]
end

.source_rootObject



13
14
15
# File 'lib/terraspace/cli/new/git_hook.rb', line 13

def self.source_root
  File.expand_path("../../../templates/base/git_hook", __dir__)
end

Instance Method Details

#createObject



17
18
19
20
21
22
23
24
25
# File 'lib/terraspace/cli/new/git_hook.rb', line 17

def create
  unless File.exist?(".git")
    puts "No .git folder found. Not creating git hook."
    return
  end
  dest = ".git/hooks/#{options[:type]}"
  template "hook.sh", dest
  chmod dest, 0755
end