Class: FastlaneCore::FastlaneFolder

Inherits:
Object
  • Object
show all
Defined in:
fastlane_core/lib/fastlane_core/fastlane_folder.rb

Constant Summary collapse

FOLDER_NAME =
'fastlane'

Class Method Summary collapse

Class Method Details

.create_folder!(path = nil) ⇒ Object



64
65
66
67
68
69
70
# File 'fastlane_core/lib/fastlane_core/fastlane_folder.rb', line 64

def self.create_folder!(path = nil)
  path = File.join(path || '.', FOLDER_NAME)
  return if File.directory?(path) # directory is already there
  UI.user_error!("Found a file called 'fastlane' at path '#{path}', please delete it") if File.exist?(path)
  FileUtils.mkdir_p(path)
  UI.success("Created new folder '#{path}'.")
end

.fastfile_pathObject

Path to the Fastfile inside the fastlane folder. This is nil when none is available



46
47
48
49
50
51
52
53
54
55
56
# File 'fastlane_core/lib/fastlane_core/fastlane_folder.rb', line 46

def self.fastfile_path
  return nil if self.path.nil?

  # Check for Swift first, because Swift is #1
  path = File.join(self.path, 'Fastfile.swift')
  return path if File.exist?(path)

  path = File.join(self.path, 'Fastfile')
  return path if File.exist?(path)
  return nil
end

.pathObject

Path to the fastlane folder containing the Fastfile and other configuration files



8
9
10
11
12
13
14
15
16
# File 'fastlane_core/lib/fastlane_core/fastlane_folder.rb', line 8

def self.path
  value ||= "./#{FOLDER_NAME}/" if File.directory?("./#{FOLDER_NAME}/")
  value ||= "./.#{FOLDER_NAME}/" if File.directory?("./.#{FOLDER_NAME}/") # hidden folder
  value ||= "./" if File.basename(Dir.getwd) == FOLDER_NAME && File.exist?('Fastfile.swift') # inside the folder
  value ||= "./" if File.basename(Dir.getwd) == ".#{FOLDER_NAME}" && File.exist?('Fastfile.swift') # inside the folder and hidden
  value ||= "./" if File.basename(Dir.getwd) == FOLDER_NAME && File.exist?('Fastfile') # inside the folder
  value ||= "./" if File.basename(Dir.getwd) == ".#{FOLDER_NAME}" && File.exist?('Fastfile') # inside the folder and hidden
  return value
end

.setup?Boolean

Does a fastlane configuration already exist?

Returns:



59
60
61
62
# File 'fastlane_core/lib/fastlane_core/fastlane_folder.rb', line 59

def self.setup?
  return false unless self.fastfile_path
  File.exist?(self.fastfile_path)
end

.swift?Boolean

Returns:



23
24
25
26
# File 'fastlane_core/lib/fastlane_core/fastlane_folder.rb', line 23

def self.swift?
  return false unless self.fastfile_path
  return self.fastfile_path.downcase.end_with?(".swift")
end

.swift_folder_pathObject



28
29
30
# File 'fastlane_core/lib/fastlane_core/fastlane_folder.rb', line 28

def self.swift_folder_path
  return File.join(self.path, 'swift')
end

.swift_runner_built?Boolean

Returns:



36
37
38
39
40
41
42
43
# File 'fastlane_core/lib/fastlane_core/fastlane_folder.rb', line 36

def self.swift_runner_built?
  swift_runner_path = self.swift_runner_path
  if swift_runner_path.nil?
    return false
  end

  return File.exist?(swift_runner_path)
end

.swift_runner_pathObject

path to the Swift runner executable if it has been built



19
20
21
# File 'fastlane_core/lib/fastlane_core/fastlane_folder.rb', line 19

def self.swift_runner_path
  return File.join(self.path, 'FastlaneRunner')
end

.swift_runner_project_pathObject



32
33
34
# File 'fastlane_core/lib/fastlane_core/fastlane_folder.rb', line 32

def self.swift_runner_project_path
  return File.join(self.swift_folder_path, 'FastlaneSwiftRunner', 'FastlaneSwiftRunner.xcodeproj')
end