Skip to content

Commit

Permalink
Added rudimentary system environment variable support. (#284)
Browse files Browse the repository at this point in the history
  • Loading branch information
mrozbarry authored Jul 11, 2020
1 parent 6a3777d commit 7a8fd62
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
2 changes: 1 addition & 1 deletion android/dotenv.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ def loadDotEnv(flavor = getCurrentFlavor()) {
f.eachLine { line ->
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].replace('"', '\\"'))
env.put(matcher[0][1], System.env[matcher[0][1]] || matcher[0][2].replace('"', '\\"'))
}
}
} else {
Expand Down
2 changes: 2 additions & 0 deletions ios/ReactNativeConfig/ReactNativeConfig.m
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ + (NSDictionary *)env {
}

+ (NSString *)envFor: (NSString *)key {
NSString *envValue = (NSString *)[[[NSProcessInfo processInfo]environment]objectForKey:key];
if (envValue) return envValue;
NSString *value = (NSString *)[self.env objectForKey:key];
return value;
}
Expand Down

0 comments on commit 7a8fd62

Please sign in to comment.