Method: Orly::Installation.install

Defined in:
lib/orly/installation.rb

.installObject



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/orly/installation.rb', line 11

def self.install
    if not File.directory?(".git")
      puts "You don't appear to be in the base directory of a git project.".red
      exit 1
    end

    Dir.mkdir(HOOK_DIR) unless File.directory?(HOOK_DIR)

    if File.exists? HOOK_PATH
      puts "A post-merge hook already exists for this project.".red
      exit 1
    end

    File.open(HOOK_PATH, 'w') {|f| f.write(HOOK_CONTENT) }
    FileUtils.chmod 0755, HOOK_PATH
    puts "installed O RLY hook as:".green
    puts "  -> #{File.expand_path(HOOK_PATH)}".green
    puts "(to remove later, you can use: orly --uninstall)"
end