gym/lib/gym/commands_generator.rb in fastlane-2.69.0.beta.20171212010004 vs gym/lib/gym/commands_generator.rb in fastlane-2.69.0
- old
+ new
@@ -43,14 +43,26 @@
end
command :init do |c|
c.syntax = "fastlane gym init"
c.description = "Creates a new Gymfile for you"
- c.action do |_args, options|
+ c.action do |args, options|
containing = FastlaneCore::Helper.fastlane_enabled_folder_path
path = File.join(containing, Gym.gymfile_name)
UI.user_error! "Gymfile already exists" if File.exist?(path)
- template = File.read("#{Gym::ROOT}/lib/assets/GymfileTemplate")
+
+ is_swift_fastfile = args.include?("swift")
+ if is_swift_fastfile
+ path = File.join(containing, Gym.gymfile_name + ".swift")
+ UI.user_error! "Gymfile.swift already exists" if File.exist?(path)
+ end
+
+ if is_swift_fastfile
+ template = File.read("#{Gym::ROOT}/lib/assets/GymfileTemplate.swift")
+ else
+ template = File.read("#{Gym::ROOT}/lib/assets/GymfileTemplate")
+ end
+
File.write(path, template)
UI.success "Successfully created '#{path}'. Open the file using a code editor."
end
end