Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

uninstall node.js if assets:precompile works

  • Loading branch information...
commit d46635a97b7f8c1697aa40fce74d428d0e66fc79 1 parent 5a46865
@hone hone authored
Showing with 10 additions and 2 deletions.
  1. +6 −2 lib/language_pack/rails3.rb
  2. +4 −0 lib/language_pack/ruby.rb
View
8 lib/language_pack/rails3.rb
@@ -2,6 +2,7 @@
require "language_pack/rails2"
class LanguagePack::Rails3 < LanguagePack::Rails2
+ NODE_JS_BINARY_PATH = 'node/node-0.4.7/node'
def self.use?
super &&
@@ -36,7 +37,7 @@ def plugins
end
def binaries
- node = gem_is_bundled?('execjs') ? ['node/node-0.4.7/node'] : []
+ node = gem_is_bundled?('execjs') ? [NODE_JS_BINARY_PATH] : []
super + node
end
@@ -46,8 +47,11 @@ def run_assets_precompile_task
run("mkdir -p tmp/cache")
# need to use a dummy DATABASE_URL here, so rails can load the environment
pipe("env RAILS_ENV=production DATABASE_URL=postgres://user:pass@127.0.0.1/dbname PATH=$PATH:bin bundle exec rake assets:precompile 2>&1")
- unless $?.success?
+ if $?.success?
+ uninstall_binary(NODE_JS_BINARY_PATH)
+ else
puts "assets:precompile task failed"
+ puts "installing node.js binary to compile assets at bootup"
end
end
end
View
4 lib/language_pack/ruby.rb
@@ -79,6 +79,10 @@ def install_binary(path)
FileUtils.cp File.join(binary_root, path), File.join('bin', File.basename(path))
end
+ def uninstall_binary(path)
+ FileUtils.rm File.join('bin', File.basename(path)), :force => true
+ end
+
def binary_root
File.expand_path("../../../vendor", __FILE__)
end
Please sign in to comment.
Something went wrong with that request. Please try again.