Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added custom ENV in resource composer_project #54

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions providers/project.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,12 @@ def make_execute(cmd)
optimize = new_resource.optimize_autoloader ? optimize_flag(cmd) : ''
prefer_dist = new_resource.prefer_dist ? '--prefer-dist' : ''
prefer_source = new_resource.prefer_source ? '--prefer-source' : ''
environment = { 'COMPOSER_HOME' => Composer.home_dir(node) }.merge(new_resource.env)

execute "#{cmd}-composer-for-project" do
cwd new_resource.project_dir
command "#{node['composer']['bin']} #{cmd} --no-interaction --no-ansi #{quiet} #{dev} #{optimize} #{prefer_dist} #{prefer_source}"
environment 'COMPOSER_HOME' => Composer.home_dir(node)
environment environment
action :run
only_if 'which composer'
user new_resource.user
Expand All @@ -57,11 +58,12 @@ def make_require
dev = new_resource.dev ? '--dev' : '--update-no-dev'
vendor = new_resource.vendor
prefer_dist = new_resource.prefer_dist ? '--prefer-dist' : ''
environment = { 'COMPOSER_HOME' => Composer.home_dir(node) }.merge(new_resource.env)

execute 'Install-composer-for-single-project' do
cwd new_resource.project_dir
command "#{node['composer']['bin']} require #{vendor} #{dev} #{prefer_dist}"
environment 'COMPOSER_HOME' => Composer.home_dir(node)
environment environment
action :run
only_if 'which composer'
user new_resource.user
Expand All @@ -72,11 +74,12 @@ def make_require

def remove_vendor(cmd)
vendor = new_resource.vendor
environment = { 'COMPOSER_HOME' => Composer.home_dir(node) }.merge(new_resource.env)

execute "#{cmd}-composer-for-project" do
cwd new_resource.project_dir
command "#{node['composer']['bin']} remove #{vendor}"
environment 'COMPOSER_HOME' => Composer.home_dir(node)
environment environment
action :run
only_if 'which composer'
end
Expand Down
1 change: 1 addition & 0 deletions resources/project.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
attribute :user, :kind_of => String, :default => 'root'
attribute :group, :kind_of => String, :default => 'root'
attribute :umask, :kind_of => [String, Fixnum], :default => 0002
attribute :env, :kind_of => [Hash], :default => {}

def initialize(*args)
super
Expand Down