Class: EmojiCommit::Cli
- Inherits:
-
Thor
- Object
- Thor
- EmojiCommit::Cli
- Defined in:
- lib/file-tasks.rb
Instance Method Summary collapse
Instance Method Details
#install ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/file-tasks.rb', line 9 def install check_for_git puts 'You are about to overwrite any existing Git commit hook with the emoji script' puts 'Is that OK? (Y|n)' answer = STDIN.gets.strip.downcase if answer == 'n' puts 'Fine whatever. Bye' exit elsif answer == '' puts 'Great, installing into .git/hooks' elsif answer != 'y' puts 'Pardon? Oh who cares. Bye' exit else puts 'Great, installing into .git/hooks' end if File.exist?('.git/hooks/commit-msg') then FileUtils.rm('.git/hooks/commit-msg') end filenames.each do |filename| FileUtils.cp("#{path}/#{filename}", ".git/hooks/#{filename}") FileUtils.chmod(0755, ".git/hooks/#{filename}") end puts 'Installed scripts successfully. Commit emoji-ful messages!' end |
#uninstall ⇒ Object
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 |
# File 'lib/file-tasks.rb', line 40 def uninstall check_for_git puts 'You are about to uninstall the emoji Git commit hook' puts 'Is that OK? (y|n)' answer = STDIN.gets.strip.downcase if answer == 'n' puts 'Good choice. Bye' exit elsif answer != 'y' puts 'Pardon? Oh who cares. Bye' exit else puts 'As long as you\'re sure :( Removing files now' end filenames.each do |filename| FileUtils.rm(".git/hooks/#{filename}") if File.exists?(".git/hooks/#{filename}") end FileUtils.cp("#{path}/commit-msg.sample", ".git/hooks/commit-msg.sample") unless File.exist?('.git/hooks/commit-msg.sample') puts 'Uninstalled scripts successfully. Enjoy your boring emoji-less life.' end |