Skip to content

Commit 43db57b

Browse files
committed
compatibilty with the node.js buildpack for installing node
1 parent b8c05ee commit 43db57b

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

lib/language_pack/ruby.rb

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ class LanguagePack::Ruby < LanguagePack::Base
2121
LEGACY_JVM_VERSION = "openjdk1.7.0_25"
2222
DEFAULT_RUBY_VERSION = "ruby-2.0.0"
2323
RBX_BASE_URL = "http://binaries.rubini.us/heroku"
24+
NODE_BP_PATH = "vendor/node/bin"
2425

2526
# detects if this is a valid Ruby app
2627
# @return [Boolean] true if it's a Ruby app
@@ -219,6 +220,7 @@ def ruby_versions
219220
def setup_language_pack_environment
220221
instrument 'ruby.setup_language_pack_environment' do
221222
setup_ruby_install_env
223+
ENV["PATH"] += ":#{node_bp_bin_path}" if node_js_installed?
222224

223225
# TODO when buildpack-env-args rolls out, we can get rid of
224226
# ||= and the manual setting below
@@ -683,7 +685,15 @@ def add_dev_database_addon
683685
# @note execjs will blow up if no JS RUNTIME is detected and is loaded.
684686
# @return [Array] the node.js binary path if we need it or an empty Array
685687
def add_node_js_binary
686-
bundler.has_gem?('execjs') ? [NODE_JS_BINARY_PATH] : []
688+
bundler.has_gem?('execjs') && !node_js_installed? ? [NODE_JS_BINARY_PATH] : []
689+
end
690+
691+
def node_bp_bin_path
692+
"#{Dir.pwd}/#{NODE_BP_PATH}"
693+
end
694+
695+
def node_js_installed?
696+
@node_js_installed ||= run("node -v", env: {"PATH" => "#{node_bp_bin_path}:#{ENV["PATH"]}" }) && $?.success?
687697
end
688698

689699
def run_assets_precompile_rake_task

0 commit comments

Comments
 (0)