Sha256: 132ded6a60a4633acb30e3d5a06362282f92863380388d999a58b7c8d886f1e5

Contents?: true

Size: 801 Bytes

Versions: 4

Compression:

Stored size: 801 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
      return unless File.exist?(".git")
      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

4 entries across 4 versions & 1 rubygems

Version Path
terraspace-0.3.3 lib/terraspace/cli/new/git_hook.rb
terraspace-0.3.2 lib/terraspace/cli/new/git_hook.rb
terraspace-0.3.1 lib/terraspace/cli/new/git_hook.rb
terraspace-0.3.0 lib/terraspace/cli/new/git_hook.rb