Sha256: 47a202249b394da86134d4ee295385ca079222fb5899772d8c70628facd70868

Contents?: true

Size: 879 Bytes

Versions: 92

Compression:

Stored size: 879 Bytes

Contents

class Terraspace::CLI::New
  class GitHook < Thor::Group
    include Thor::Actions

    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
    cli_options.each { |args| class_option(*args) }

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

    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

  private
    def terraspace_build_commands
      code = []
      @options[:envs].each do |env|
        code << %Q|TS_ENV=#{env} terraspace build|
      end
      code.join("\n")
    end
  end
end

Version data entries

92 entries across 92 versions & 1 rubygems

Version Path
terraspace-2.2.17 lib/terraspace/cli/new/git_hook.rb
terraspace-2.2.16 lib/terraspace/cli/new/git_hook.rb
terraspace-2.2.15 lib/terraspace/cli/new/git_hook.rb
terraspace-2.2.14 lib/terraspace/cli/new/git_hook.rb
terraspace-2.2.13 lib/terraspace/cli/new/git_hook.rb
terraspace-2.2.12 lib/terraspace/cli/new/git_hook.rb
terraspace-2.2.11 lib/terraspace/cli/new/git_hook.rb
terraspace-2.2.10 lib/terraspace/cli/new/git_hook.rb
terraspace-2.2.9 lib/terraspace/cli/new/git_hook.rb
terraspace-2.2.8 lib/terraspace/cli/new/git_hook.rb
terraspace-2.2.7 lib/terraspace/cli/new/git_hook.rb
terraspace-2.2.6 lib/terraspace/cli/new/git_hook.rb
terraspace-2.2.5 lib/terraspace/cli/new/git_hook.rb
terraspace-2.2.4 lib/terraspace/cli/new/git_hook.rb
terraspace-2.2.3 lib/terraspace/cli/new/git_hook.rb
terraspace-2.2.2 lib/terraspace/cli/new/git_hook.rb
terraspace-2.2.1 lib/terraspace/cli/new/git_hook.rb
terraspace-2.2.0 lib/terraspace/cli/new/git_hook.rb
terraspace-2.1.7 lib/terraspace/cli/new/git_hook.rb
terraspace-2.1.6 lib/terraspace/cli/new/git_hook.rb