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
|
# File 'lib/toga/commands/init.rb', line 9
def self.run!(args)
dir = File.expand_path args.first
FileUtils.mkdir_p dir if !File.directory?(dir)
new_togafile = File.expand_path(File.join(dir, Toga::TOGAFILE_NAME))
unless File.exists?(new_togafile)
File.open(new_togafile, 'w') do |f|
togafile = File.expand_path(File.join(Toga::SCAFFOLD_PATH, Toga::TOGAFILE_NAME))
f.write File.open(togafile).read
end
end
begin
git = Git.open(File.expand_path(File.join(dir)))
if !git.status.ignored.keys.include?(Toga::TOGAFILE_NAME)
File.open(File.expand_path(File.join(dir, '.git/info/exclude')), 'a') do |f|
f.write Toga::TOGAFILE_NAME
f.write "\n"
f.write Toga::CONFIGFILE_NAME
end
end
rescue
puts "Couldn't find .gitignore, so Togafile won't be ignored by git."
end
"Created #{Toga::TOGAFILE_NAME} in #{dir}."
end
|