5
6
7
8
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
38
39
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
66
67
|
# File 'lib/inkcite/cli/init.rb', line 5
def self.invoke path, opts
full_init_path = File.expand_path(path)
abort "It appears that an Inkcite already exists in #{path}" if File.exist?(File.join(full_init_path, 'config.yml'))
from_path = opts[:from]
is_empty = opts[:empty]
is_new = from_path.blank?
if is_new
from_path = File.join(Inkcite.asset_path, 'init')
elsif is_empty
abort "Can't initialize a project using --empty and --from at the same time"
end
init_image_path = File.join(path, Inkcite::Email::IMAGES)
full_init_image_path = File.join(full_init_path, Inkcite::Email::IMAGES)
FileUtils.mkpath(full_init_image_path)
puts "Created #{init_image_path}"
abort "Can't find #{from_path} or it isn't an existing Inkcite project" unless File.exist?(File.join(from_path, 'config.yml'))
Dir.glob(File.join(from_path, '*.{html,tsv,txt,yml}')).each do |from_file|
FileUtils.cp(from_file, full_init_path)
puts "Created #{File.join(path, from_file)}"
end
if is_new && !is_empty
from_path = File.join(Inkcite.asset_path, 'example')
FileUtils.cp_r(File.join(from_path, '.'), full_init_path)
puts 'Copied example email files'
end
from_path = File.join(from_path, Inkcite::Email::IMAGES)
if File.exist?(from_path)
FileUtils.cp_r(File.join(from_path, '.'), full_init_image_path)
puts "Copied images to #{init_image_path}"
end
end
|