lib/ember-cli/app.rb in ember-cli-rails-0.0.5 vs lib/ember-cli/app.rb in ember-cli-rails-0.0.6

- old
+ new

@@ -1,23 +1,22 @@ module EmberCLI class App attr_reader :name, :options, :pid - def initialize(name, **options) + def initialize(name, options={}) @name, @options = name.to_s, options end def compile - symlink_to_assets_root - add_assets_to_precompile_list + prepare silence_stream STDOUT do system command, chdir: app_path, err: :out end end def run - compile + prepare @pid = spawn(command(watch: true), chdir: app_path, err: :out) at_exit{ stop } end def stop @@ -33,20 +32,28 @@ delegate :ember_path, to: :configuration delegate :tee_path, to: :configuration delegate :configuration, to: :EmberCLI + def prepare + @prepared ||= begin + symlink_to_assets_root + add_assets_to_precompile_list + true + end + end + def symlink_to_assets_root assets_path.join(name).make_symlink dist_path.join("assets") end def add_assets_to_precompile_list Rails.configuration.assets.precompile << /(?:\/|\A)#{name}\// end - def command(watch: nil) - watch = "--watch" if watch + def command(options={}) + watch = options[:watch] ? "--watch" : "" "#{ember_path} build #{watch} --environment #{environment} --output-path #{dist_path} #{log_pipe}" end def log_pipe "| #{tee_path} -a #{log_path}" if tee_path @@ -73,9 +80,9 @@ def assets_path @assets_path ||= EmberCLI.root.join("assets").tap(&:mkpath) end def environment - Rails.env.in?(%w[development test]) ? Rails.env : "production" + Helpers.non_production?? "development" : "production" end end end