diff --git a/attributes/default.rb b/attributes/default.rb index 5206fa3..c0f5a2c 100644 --- a/attributes/default.rb +++ b/attributes/default.rb @@ -21,4 +21,5 @@ end default['composer']['global_configs'] = {} +default['composer']['home_dir'] = nil default['composer']['php_recipe'] = 'php::default' diff --git a/recipes/global_configs.rb b/recipes/global_configs.rb index dea93b5..be8cdfc 100644 --- a/recipes/global_configs.rb +++ b/recipes/global_configs.rb @@ -16,6 +16,10 @@ 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| @@ -23,7 +27,7 @@ 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 @@ -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 diff --git a/recipes/self_update.rb b/recipes/self_update.rb index 72ae9e7..8cb4e15 100644 --- a/recipes/self_update.rb +++ b/recipes/self_update.rb @@ -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