Class: Fastlane::FastlaneFolder

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

Constant Summary collapse

FOLDER_NAME =
'fastlane'

Class Method Summary collapse

Class Method Details

.available_lanesObject

Returns an array of symbols for the available lanes for the Fastfile This doesn’t actually use the Fastfile parser, but only the available lanes. This way it’s much faster Use this only if performance is :key:



39
40
41
42
43
# File 'lib/fastlane/fastlane_folder.rb', line 39

def self.available_lanes
  return [] if fastfile_path.nil?
  output = `cat #{fastfile_path.shellescape} | grep \"^\s*lane \:\" | awk -F ':' '{print $2}' | awk -F ' ' '{print $1}'`
  return output.strip.split(" ").collect(&:to_sym)
end

.create_folder!(path = nil) ⇒ Object



29
30
31
32
33
# File 'lib/fastlane/fastlane_folder.rb', line 29

def self.create_folder!(path = nil)
  path = File.join(path || '.', FOLDER_NAME)
  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



17
18
19
20
21
# File 'lib/fastlane/fastlane_folder.rb', line 17

def self.fastfile_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



6
7
8
9
10
11
12
13
14
# File 'lib/fastlane/fastlane_folder.rb', line 6

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') # inside the folder
  value ||= "./" if File.basename(Dir.getwd) == ".#{FOLDER_NAME}" && File.exist?('Fastfile') # inside the folder and hidden

  value = nil if Helper.is_test? # this is required, as the tests would use the ./fastlane folder otherwise
  return value
end

.setup?Boolean

Does a fastlane configuration already exist?

Returns:

  • (Boolean)


24
25
26
27
# File 'lib/fastlane/fastlane_folder.rb', line 24

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