Skip to content

Commit b6d54e3

Browse files
committed
stop storing items in tmp/ directory,
only copy ember from gem when local over-ride / update not present
1 parent 9f2f956 commit b6d54e3

File tree

1 file changed

+19
-12
lines changed

1 file changed

+19
-12
lines changed

lib/ember_rails.rb

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -22,23 +22,30 @@ class Railtie < ::Rails::Railtie
2222

2323
initializer "ember_rails.setup_vendor", :after => "ember_rails.setup", :group => :all do |app|
2424
variant = app.config.ember.variant || (::Rails.env.production? ? :production : :development)
25-
26-
# Copy over the desired ember, ember-data, and handlebars bundled in
27-
# ember-source, ember-data-source, and handlebars-source to a tmp folder.
28-
tmp_path = app.root.join("tmp/ember-rails")
2925
ext = variant == :production ? ".prod.js" : ".js"
30-
FileUtils.mkdir_p(tmp_path)
31-
FileUtils.cp(::Ember::Source.bundled_path_for("ember#{ext}"), tmp_path.join("ember.js"))
32-
FileUtils.cp(::Ember::Data::Source.bundled_path_for("ember-data#{ext}"), tmp_path.join("ember-data.js"))
33-
app.assets.append_path(tmp_path)
26+
27+
#Allow for over-rides and updates, empty /bundler to avoid duplicate files
28+
ember_path = app.root.join("vendor/assets/ember/#{variant}")
29+
bundled_path = ember_path.join("bundler")
30+
FileUtils.mkdir_p(bundled_path)
31+
FileUtils.rm_rf(Dir.glob("#{bundled_path}/*"))
32+
33+
# Check for over-rides, else store the bundled ember and ember-data in /bundler
34+
if !File.exist?(ember_path.join("ember.js"))
35+
FileUtils.cp(::Ember::Source.bundled_path_for("ember#{ext}"),
36+
bundled_path.join("ember.js"))
37+
end
38+
if !File.exist?(ember_path.join("ember-data.js"))
39+
FileUtils.cp(::Ember::Data::Source.bundled_path_for("ember-data#{ext}"),
40+
bundled_path.join('ember-data.js'))
41+
end
42+
43+
app.assets.prepend_path(ember_path)
44+
app.assets.append_path(bundled_path)
3445

3546
# Make the handlebars.js and handlebars.runtime.js bundled
3647
# in handlebars-source available.
3748
app.assets.append_path(File.expand_path('../', ::Handlebars::Source.bundled_path))
38-
39-
# Allow a local variant override
40-
ember_path = app.root.join("vendor/assets/ember/#{variant}")
41-
app.assets.prepend_path(ember_path.to_s) if ember_path.exist?
4249
end
4350

4451
initializer "ember_rails.es5_default", :group => :all do |app|

0 commit comments

Comments
 (0)