Sha256: 42c91117ee5e553f5c2dcfb97e1d9fcada581439ac9cf5a7f9d7354dedf9ddf7

Contents?: true

Size: 1.01 KB

Versions: 1

Compression:

Stored size: 1.01 KB

Contents

require_relative 'action'
module Arli
  module Actions
    class GitRepo < Action

      def act
        c = library.exists? ? git_update_command : git_clone_command
        ___ 'running ' + c.blue + ' '
        execute(c)
        ok
      rescue Exception => e
        fuck
        raise e
      end

      def git_update_command
        "cd #{path} && git pull --rebase 2>&1"
      end

      def git_clone_command
        "git clone -v #{library.url} #{path} 2>&1"
      end

      protected

      # @param <String> *args — list of arguments or a single string
      def execute(*args)
        cmd = args.join(' ')
        raise 'No command to run was given' unless cmd
        info("\n" + cmd.green) if Arli.debug?
        o, e, s = Open3.capture3(cmd)
        info("\n" + o) if o if Arli.debug?
        info("\n" + e.red) if e && Arli.debug?
      rescue Exception => e
        error "Error running [#{args.join(' ')}]\n" +
                "Current folder is [#{Dir.pwd.yellow}]", e
        raise e
      end


    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
arli-0.6.1 lib/arli/actions/git_repo.rb