lib/ember-cli/app.rb in ember-cli-rails-0.0.15 vs lib/ember-cli/app.rb in ember-cli-rails-0.0.16

- old
+ new

@@ -12,18 +12,17 @@ @name, @options = name.to_s, options end def compile prepare - silence_stream STDOUT do - system(env_hash, command, chdir: app_path, err: :out) - end + silence_stream(STDOUT){ exec command } end def run prepare - @pid = spawn(env_hash, command(watch: true), chdir: app_path, err: :out) + cmd = command(watch: true) + @pid = exec(cmd, method: :spawn) at_exit{ stop } end def stop Process.kill "INT", pid if pid @@ -66,13 +65,21 @@ ============================= WARNING! ============================= MSG end + def ember_path + @ember_path ||= app_path.join("node_modules", ".bin", "ember").tap do |path| + fail <<-MSG.strip_heredoc unless path.executable? + No local ember executable found. You should run `npm install` + inside the #{name} app located at #{app_path} + MSG + end + end + private - delegate :ember_path, to: :configuration delegate :match_version?, :non_production?, to: Helpers delegate :tee_path, to: :configuration delegate :configuration, to: :EmberCLI def build_timeout @@ -194,16 +201,24 @@ package_json.fetch("devDependencies", {}) end def addon_present? dev_dependencies["ember-cli-rails-addon"] == ADDON_VERSION && - app_path.join('node_modules', 'ember-cli-rails-addon', 'package.json').exist? + app_path.join("node_modules", "ember-cli-rails-addon", "package.json").exist? end def env_hash ENV.clone.tap do |vars| vars.store "DISABLE_FINGERPRINTING", "true" vars.store "SUPPRESS_JQUERY", "true" if suppress_jquery? + end + end + + def exec(cmd, options={}) + method_name = options.fetch(:method, :system) + + Dir.chdir app_path do + Kernel.public_send(method_name, env_hash, cmd, err: :out) end end end end