Skip to content

Commit

Permalink
Allow exported variables in .env (lugg#116)
Browse files Browse the repository at this point in the history
  • Loading branch information
bendyorke authored and Pedro Belo committed Jun 21, 2017
1 parent 6213351 commit 46b7f94
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion android/dotenv.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def readDotEnv = {
println("Reading env from: $envFile")
try {
new File("$project.rootDir/../$envFile").eachLine { line ->
def matcher = (line =~ /^\s*([\w\d\.\-_]+)\s*=\s*(.*)?\s*$/)
def matcher = (line =~ /^\s*(?:export\s+|)([\w\d\.\-_]+)\s*=\s*['"]?(.*)?['"]?\s*$/)
if (matcher.getCount() == 1 && matcher[0].size() == 3){
env.put(matcher[0][1], matcher[0][2])
}
Expand Down
4 changes: 2 additions & 2 deletions ios/ReactNativeConfig/BuildDotenvConfig.ruby
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ end
puts "Reading env from #{file}"

dotenv = begin
# https://regex101.com/r/SLdbes/1
dotenv_pattern = /^(?<key>[[:alnum:]_]+)=((?<quote>["'])?(?<val>.*?[^\\])\k<quote>?|)$/
# https://regex101.com/r/aFZMSB
dotenv_pattern = /^(?:export\s+|)(?<key>[[:alnum:]_]+)=((?<quote>["'])?(?<val>.*?[^\\])\k<quote>?|)$/
# find that above node_modules/react-native-config/ios/
raw = File.read(File.join(Dir.pwd, "../../../#{file}"))
raw.split("\n").inject({}) do |h, line|
Expand Down

0 comments on commit 46b7f94

Please sign in to comment.