lib/ember_cli/path_set.rb in ember-cli-rails-0.8.5 vs lib/ember_cli/path_set.rb in ember-cli-rails-0.8.6

- old
+ new

@@ -33,10 +33,14 @@ def gemfile @gemfile ||= root.join("Gemfile") end + def bower_json + ember_cli_root.join("bower.json") + end + def ember @ember ||= begin root.join("node_modules", "ember-cli", "bin", "ember").tap do |path| unless path.executable? fail DependencyError.new <<-MSG.strip_heredoc @@ -44,10 +48,11 @@ Install it: $ cd #{root} $ #{package_manager} install + MSG end end end end @@ -60,20 +65,19 @@ @build_error_file ||= tmp.join("error.txt") end def bower @bower ||= begin - bower_path = app_options.fetch(:bower_path) { which("bower") } - - bower_path.tap do |path| - unless Pathname(path.to_s).executable? + path_for_executable("bower").tap do |bower_path| + if bower_json.exist? && (bower_path.blank? || !bower_path.executable?) fail DependencyError.new <<-MSG.strip_heredoc - Bower is required by EmberCLI + Bower is required by EmberCLI - Install it with: + Install it with: - $ npm install -g bower + $ npm install -g bower + MSG end end end end @@ -81,35 +85,43 @@ def bower_components @bower_components ||= root.join("bower_components") end def npm - @npm ||= app_options.fetch(:npm_path) { which("npm") } + @npm ||= path_for_executable("npm") end def yarn if yarn? - @yarn ||= app_options.fetch(:yarn_path) { which("yarn") } + @yarn ||= path_for_executable("yarn") end end def node_modules @node_modules ||= root.join("node_modules") end def tee - @tee ||= app_options.fetch(:tee_path) { which("tee") } + @tee ||= path_for_executable("tee") end def bundler - @bundler ||= app_options.fetch(:bundler_path) { which("bundler") } + @bundler ||= path_for_executable("bundler") end private attr_reader :app, :ember_cli_root, :environment, :rails_root + def path_for_executable(command) + path = app_options.fetch("#{command}_path") { which(command) } + + if path.present? + Pathname.new(path) + end + end + def package_manager if yarn? "yarn" else "npm" @@ -123,10 +135,10 @@ def app_name app.name end def app_options - app.options + app.options.with_indifferent_access end def which(executable) Helpers.which(executable) end