Merge pull request #31 from skellock/fix-missing-env

Fix missing env
This commit is contained in:
Pedro Belo 2016-09-13 18:20:55 -07:00 committed by GitHub
commit 4747803915
2 changed files with 13 additions and 7 deletions

View File

@ -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)
}

View File

@ -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}"
puts "Wrote to #{path}"