26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
|
# File 'lib/hooky/cli.rb', line 26
def init
require "fileutils"
unless (example_dir = Pathname.new(File.expand_path(".hooky/example"))).exist?
example_dir.mkpath
Pathname.new(File.expand_path("templates/example_hook", __dir__)).each_child do |sample_hook|
FileUtils.cp sample_hook, example_dir, preserve: true
end
puts "Created example hook in .hooky/example"
end
if (binstub = Pathname.new(File.expand_path("bin/hooky"))).exist?
puts "Binstub already exists in bin/hooky (remove first to create a new one)"
else
puts "Adding hookyrb to Gemfile and bundle..."
`bundle add hooky --group "development, test"`
`bundle binstubs hooky`
puts "Created binstub file in bin/hooky"
end
end
|