take custom env for ios in a file :{ /tmp/envfile

not great but dunno how to do it otherwise yet
This commit is contained in:
Pedro Belo 2016-03-03 16:34:45 -08:00
parent e430e2acbf
commit 57ea6c3a03
2 changed files with 19 additions and 3 deletions

View File

@ -2,8 +2,20 @@
require "json"
# find the project dotenv file above node_modules/react-native-config/ios/
dotenv = File.read(File.join(Dir.pwd, "../../../.env")).split("\n").inject({}) do |h, line|
# defaults
file = ".env"
custom_env = false
# pick a custom env file if set
if File.exists?("/tmp/envfile")
custom_env = true
file = File.read("/tmp/envfile").strip
end
puts "Reading env from #{file}"
# find that above node_modules/react-native-config/ios/
dotenv = File.read(File.join(Dir.pwd, "../../../#{file}")).split("\n").inject({}) do |h, line|
key, val = line.split("=", 2)
h.merge!(key => val)
end
@ -18,4 +30,8 @@ EOF
path = File.join(ENV["SYMROOT"], "GeneratedDotEnv.m")
File.open(path, "w") { |f| f.puts template }
puts "Wrote to #{path}"
if custom_env
File.delete("/tmp/envfile")
end
puts "Wrote to #{path}"