From e04cc0d71e3a2f5c7735673443d3e042a3c0c629 Mon Sep 17 00:00:00 2001 From: Steve Kellock Date: Sun, 28 Aug 2016 21:03:52 -0400 Subject: [PATCH 1/2] Prevents dying in a fire on iOS with a missing .env file. --- ios/ReactNativeConfig/BuildDotenvConfig.ruby | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ios/ReactNativeConfig/BuildDotenvConfig.ruby b/ios/ReactNativeConfig/BuildDotenvConfig.ruby index 5b658c6..b0ea95e 100755 --- a/ios/ReactNativeConfig/BuildDotenvConfig.ruby +++ b/ios/ReactNativeConfig/BuildDotenvConfig.ruby @@ -18,7 +18,7 @@ puts "Reading env from #{file}" dotenv = File.read(File.join(Dir.pwd, "../../../#{file}")).split("\n").inject({}) do |h, line| key, val = line.split("=", 2) h.merge!(key => val) -end +end rescue {} # create obj file that sets DOT_ENV as a NSDictionary dotenv_objc = dotenv.map { |k, v| %Q(@"#{k}":@"#{v}") }.join(",") @@ -34,4 +34,4 @@ if custom_env File.delete("/tmp/envfile") end -puts "Wrote to #{path}" \ No newline at end of file +puts "Wrote to #{path}" From dcec930aa1d59e6817d7588b5372b6b2227e7b28 Mon Sep 17 00:00:00 2001 From: Steve Kellock Date: Sun, 28 Aug 2016 21:20:09 -0400 Subject: [PATCH 2/2] Prevents killing the android build with a missing .env file. --- android/dotenv.gradle | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/android/dotenv.gradle b/android/dotenv.gradle index 39a2afc..dd1bba2 100644 --- a/android/dotenv.gradle +++ b/android/dotenv.gradle @@ -2,11 +2,17 @@ def readDotEnv = { def env = [:] def envFile = System.env['ENVFILE'] ?: ".env" println("Reading env from: $envFile") - new File("$project.rootDir/../$envFile").eachLine { line -> - def (key, val) = line.tokenize('=') - if (key && val && key.substring(0, 1) != "#") { - env.put(key, val) - } + try { + new File("$project.rootDir/../$envFile").eachLine { line -> + def (key, val) = line.tokenize('=') + if (key && val && key.substring(0, 1) != "#") { + env.put(key, val) + } + } + } catch (Exception ex) { + println("**************************") + println("*** Missing .env file ****") + println("**************************") } project.ext.set("env", env) }