From 8dbf33c4f1dacb2c6208671feac6f0e87c4ede06 Mon Sep 17 00:00:00 2001 From: Stefano Formicola Date: Wed, 24 May 2023 15:17:35 +0000 Subject: [PATCH 1/3] feat: add support for iOS specific envs Variables whose key start with `IOS_` are rewritten without the platform prefix --- ios/ReactNativeConfig/ReadDotEnv.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ios/ReactNativeConfig/ReadDotEnv.rb b/ios/ReactNativeConfig/ReadDotEnv.rb index 6f809140..8b119d22 100755 --- a/ios/ReactNativeConfig/ReadDotEnv.rb +++ b/ios/ReactNativeConfig/ReadDotEnv.rb @@ -48,7 +48,7 @@ def read_dot_env(envs_root) abort('Invalid entry in .env file. Please verify your .env file is correctly formatted.') end - key = m[:key] + key = m[:key].sub(/^IOS_/, '') # Ensure string (in case of empty value) and escape any quotes present in the value. val = m[:val].to_s.gsub('"', '\"') h.merge(key => val) From ccb19ceab6fbfb27ce2f46d6354f7074570d0d4d Mon Sep 17 00:00:00 2001 From: Stefano Formicola Date: Wed, 24 May 2023 15:35:31 +0000 Subject: [PATCH 2/3] feat(ios): ignore Android specific envs --- ios/ReactNativeConfig/ReadDotEnv.rb | 3 +++ 1 file changed, 3 insertions(+) diff --git a/ios/ReactNativeConfig/ReadDotEnv.rb b/ios/ReactNativeConfig/ReadDotEnv.rb index 8b119d22..a4c53b76 100755 --- a/ios/ReactNativeConfig/ReadDotEnv.rb +++ b/ios/ReactNativeConfig/ReadDotEnv.rb @@ -48,6 +48,9 @@ def read_dot_env(envs_root) abort('Invalid entry in .env file. Please verify your .env file is correctly formatted.') end + # Skip if key starts with "ANDROID_" + next h if key.start_with?("ANDROID_") + # Strip IOS_ prefix if exists key = m[:key].sub(/^IOS_/, '') # Ensure string (in case of empty value) and escape any quotes present in the value. val = m[:val].to_s.gsub('"', '\"') From bee2e304ed4276f9e1b12c7f16661f4364715bbd Mon Sep 17 00:00:00 2001 From: Stefano Formicola Date: Thu, 1 Jun 2023 12:24:22 +0200 Subject: [PATCH 3/3] hotfix: skip if m[:key] starts with ANDROID_ --- ios/ReactNativeConfig/ReadDotEnv.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ios/ReactNativeConfig/ReadDotEnv.rb b/ios/ReactNativeConfig/ReadDotEnv.rb index a4c53b76..305b4dc4 100755 --- a/ios/ReactNativeConfig/ReadDotEnv.rb +++ b/ios/ReactNativeConfig/ReadDotEnv.rb @@ -48,8 +48,8 @@ def read_dot_env(envs_root) abort('Invalid entry in .env file. Please verify your .env file is correctly formatted.') end - # Skip if key starts with "ANDROID_" - next h if key.start_with?("ANDROID_") + # Skip if m[:key] starts with "ANDROID_" + next h if m[:key].start_with?("ANDROID_") # Strip IOS_ prefix if exists key = m[:key].sub(/^IOS_/, '') # Ensure string (in case of empty value) and escape any quotes present in the value.