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
|
# File 'lib/mako/scaffold.rb', line 12
def create name
path = nil
type = prioritize(:type, @args, @default)
devkit_path = prioritize(:dev_kit, @args, @settings, @default)
output_path = prepare_output_path @args, @default
if devkit_path.empty?
puts "Mako can't find your Materia Dev Kit".red
puts "Please set MAKO_DEV_KIT environment variable or the --dev-kit option".red
abort
end
if path.nil?
output_path = output_path+"/"+name.gsub(" ", "-").downcase
else
output_path = output_path+"/"+path+"/"+name.gsub(" ", "-").downcase
end
if File.exist?(output_path)
puts "Error:"+"#{output_path} already exists! Aborting!".red
abort
end
source_dir = devkit_path+'templates/'+type
puts source_dir
if File::exists? source_dir
FileUtils.cp_r source_dir, output_path
FileUtils.chmod 0777, output_path
set_name output_path, name
end
output = "Created scaffold of type "+type
puts output.green
end
|