class Fastlane::Actions::SourceEnvFromFileAction
Public Class Methods
available_options()
click to toggle source
# File lib/fastlane/plugin/source_env_from_file/actions/source_env_from_file_action.rb, line 52 def self.available_options [ FastlaneCore::ConfigItem.new( key: :filepath, description: "filepath for env key=value file", verify_block: proc do |value| UI.user_error!("No filepath given") unless (value and not value.empty?) UI.error("file not exist: #{value}") unless File.exist?(value) end ) ] end
description()
click to toggle source
# File lib/fastlane/plugin/source_env_from_file/actions/source_env_from_file_action.rb, line 40 def self.description "set ENV['key']=value from file like key=value" end
details()
click to toggle source
# File lib/fastlane/plugin/source_env_from_file/actions/source_env_from_file_action.rb, line 48 def self.details "set ENV['key']=value from file like key=value" end
example_code()
click to toggle source
# File lib/fastlane/plugin/source_env_from_file/actions/source_env_from_file_action.rb, line 69 def self.example_code [ 'source_env_from_file(filepath: "/Users/xiongzenghui/Desktop/env_data") pp ENV["XXX"]' ] end
is_supported?(platform)
click to toggle source
# File lib/fastlane/plugin/source_env_from_file/actions/source_env_from_file_action.rb, line 65 def self.is_supported?(platform) true end
run(params)
click to toggle source
# File lib/fastlane/plugin/source_env_from_file/actions/source_env_from_file_action.rb, line 7 def self.run(params) filepath = params[:filepath] IO.foreach(filepath) {|line| aline = line.gsub('export', '') # UI.important "aline: #{aline}" # key='value' mach_result = /(.*)=\"(.*)\"/.match(aline) # key=value unless mach_result mach_result = /(.*)=(.*)/.match(aline) end # key=value unless mach_result mach_result = /(.*)=(.*)/.match(aline) end next unless mach_result key = mach_result[1] value = mach_result[2] if key && value key.strip! value.strip! # UI.important "#{key}=#{value}" ENV[key] = value end } end