Skip to content

Commit

Permalink
ios support for comments, tweak error behavior to match Android
Browse files Browse the repository at this point in the history
  • Loading branch information
pedro committed Sep 14, 2016
1 parent af611c9 commit 493727d
Showing 1 changed file with 18 additions and 5 deletions.
23 changes: 18 additions & 5 deletions ios/ReactNativeConfig/BuildDotenvConfig.ruby
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,24 @@ 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 rescue {}
dotenv = begin
# find that above node_modules/react-native-config/ios/
raw = File.read(File.join(Dir.pwd, "../../../#{file}"))
raw.split("\n").inject({}) do |h, line|
key, val = line.split("=", 2)
if line.strip.empty? or line.start_with?('#')
h
else
key, val = line.split("=", 2)
h.merge!(key => val)
end
end
rescue Errno::ENOENT
puts("**************************")
puts("*** Missing .env file ****")
puts("**************************")
{} # set dotenv as an empty hash
end

# create obj file that sets DOT_ENV as a NSDictionary
dotenv_objc = dotenv.map { |k, v| %Q(@"#{k}":@"#{v}") }.join(",")
Expand Down

0 comments on commit 493727d

Please sign in to comment.