clean up file/directory interaction, add some tests
This commit is contained in:
+6
-5
@@ -79,14 +79,15 @@ private ######################################################################
|
||||
end
|
||||
|
||||
def engine
|
||||
root = File.expand_path(File.dirname(procfile))
|
||||
env = File.expand_path(File.join(root, ".env"))
|
||||
@engine ||= Foreman::Engine.new(procfile, options.merge({:app_root => root,
|
||||
:env => env}))
|
||||
@engine ||= Foreman::Engine.new(procfile, options)
|
||||
end
|
||||
|
||||
def procfile
|
||||
options[:procfile] || "Procfile"
|
||||
case
|
||||
when options[:procfile] then options[:procfile]
|
||||
when options[:app_root] then File.expand_path(File.join(options[:app_root], "Procfile"))
|
||||
else "Procfile"
|
||||
end
|
||||
end
|
||||
|
||||
def error(message)
|
||||
|
||||
+10
-2
@@ -22,10 +22,12 @@ class Foreman::Engine
|
||||
|
||||
def initialize(procfile, options={})
|
||||
@procfile = Foreman::Procfile.new(procfile)
|
||||
@directory = options[:app_root]
|
||||
@directory = options[:app_root] || File.expand_path(File.dirname(procfile))
|
||||
@options = options.dup
|
||||
@environment = read_environment_files(options[:env])
|
||||
@output_mutex = Mutex.new
|
||||
|
||||
@options[:env] ||= default_env
|
||||
@environment = read_environment_files(@options[:env])
|
||||
end
|
||||
|
||||
def start
|
||||
@@ -216,4 +218,10 @@ private ######################################################################
|
||||
|
||||
environment
|
||||
end
|
||||
|
||||
def default_env
|
||||
env = File.join(directory, ".env")
|
||||
File.exists?(env) ? env : ""
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user