Skip to content

Commit

Permalink
Modify asset templates for test_app
Browse files Browse the repository at this point in the history
  • Loading branch information
aishmita-aggarwal authored and Mafi88 committed Mar 14, 2016
1 parent 0a381cd commit ba3472f
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 4 deletions.
18 changes: 18 additions & 0 deletions core/lib/generators/spree/install/install_generator.rb
Expand Up @@ -195,5 +195,23 @@ def complete
puts "Enjoy!"
end
end

protected

def javascript_exists?(script)
extensions = %w(.coffee .erb .coffee.erb) + [""]
file_exists?(extensions, script)
end

def stylesheet_exists?(stylesheet)
extensions = %w(.scss .erb .scss.erb) + [""]
file_exists?(extensions, stylesheet)
end

def file_exists?(extensions, filename)
extensions.detect do |extension|
File.exists?("#{filename}.css#{extension}")
end
end
end
end
Expand Up @@ -8,6 +8,10 @@
//= require jquery_ujs
//= require spree/backend
<% unless options[:lib_name] == 'spree' || options[:lib_name] == 'spree/backend' %>
//= require spree/backend/<%= options[:lib_name].gsub("/", "_") %>
<% filename = "spree/backend/#{ options[:lib_name].gsub("/", "_") }" %>
<% filepath = File.join(File.dirname(__FILE__), "../../app/assets/javascripts/#{filename}") %>
<% if javascript_exists?(filepath) %>
//= require <%= filename %>
<% end %>
<% end %>
//= require_tree .
Expand Up @@ -8,6 +8,10 @@
//= require jquery_ujs
//= require spree/frontend
<% unless options[:lib_name] == 'spree' || options[:lib_name] == 'spree/frontend' %>
//= require spree/frontend/<%= options[:lib_name].gsub("/", "_") %>
<% filename = "spree/frontend/#{ options[:lib_name].gsub("/", "_") }" %>
<% filepath = File.join(File.dirname(__FILE__), "../../app/assets/javascripts/#{ filename }") %>
<% if javascript_exists?(filepath) %>
//= require <%= filename %>
<% end %>
<% end %>
//= require_tree .
Expand Up @@ -5,7 +5,11 @@
*
*= require spree/backend
<% unless options[:lib_name] == 'spree' || options[:lib_name] == 'spree/backend' %>
*= require spree/backend/<%= options[:lib_name].gsub("/", "_") %>
<% filename = "spree/backend/#{ options[:lib_name].gsub("/", "_") }" %>
<% filepath = File.join(File.dirname(__FILE__), "../../app/assets/stylesheets/#{ filename }") %>
<% if stylesheet_exists?(filepath) %>
*= require <%= filename %>
<% end %>
<% end %>
*= require_self
*= require_tree .
Expand Down
Expand Up @@ -5,7 +5,11 @@
*
*= require spree/frontend
<% unless options[:lib_name] == 'spree' || options[:lib_name] == 'spree/frontend' %>
*= require spree/frontend/<%= options[:lib_name].gsub("/", "_") %>
<% filename = "spree/frontend/#{ options[:lib_name].gsub("/", "_") }" %>
<% filepath = File.join(File.dirname(__FILE__), "../../app/assets/stylesheets/#{ filename }") %>
<% if stylesheet_exists?(filepath) %>
*= require <%= filename %>
<% end %>
<% end %>
*= require_self
*= require_tree .
Expand Down

0 comments on commit ba3472f

Please sign in to comment.