Skip to content

Commit

Permalink
Merge branch 'hugofonseca-composer_home'
Browse files Browse the repository at this point in the history
  • Loading branch information
djoos committed Dec 1, 2014
2 parents 5d5bfa9 + af17c10 commit b2307ac
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
1 change: 1 addition & 0 deletions attributes/default.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,5 @@
end

default['composer']['global_configs'] = {}
default['composer']['home_dir'] = nil
default['composer']['php_recipe'] = 'php::default'
8 changes: 6 additions & 2 deletions recipes/global_configs.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,18 @@
action :create
end

if node['composer']['home_dir'].nil?
node.set['composer']['home_dir'] = "/home/#{user}/.composer"
end

user_configs.nil? && next

user_configs.each_pair do |option, value|
if value.respond_to?(:each_pair)
value.each_pair do |value_k, value_v|
execute "composer-config-for-#{user}" do
command "composer config --global #{option}.#{value_k} #{value_v}"
environment 'COMPOSER_HOME' => node['composer']['install_dir']
environment 'COMPOSER_HOME' => node['composer']['home_dir']
user user
group user
action :run
Expand All @@ -32,7 +36,7 @@
else
execute "composer-config-for-#{user}" do
command "composer config --global #{option} #{value}"
environment 'COMPOSER_HOME' => node['composer']['install_dir']
environment 'COMPOSER_HOME' => node['composer']['home_dir']
user user
group user
action :run
Expand Down
6 changes: 5 additions & 1 deletion recipes/self_update.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,14 @@

include_recipe 'composer::install'

if node['composer']['home_dir'].nil?
node.set['composer']['home_dir'] = node['composer']['install_dir']
end

execute 'composer-self_update' do
cwd node['composer']['install_dir']
command 'composer self-update'
environment 'COMPOSER_HOME' => node['composer']['install_dir']
environment 'COMPOSER_HOME' => node['composer']['home_dir']
action :run
ignore_failure true
end

0 comments on commit b2307ac

Please sign in to comment.