Permalink
Browse files

skip carton install if target library path exists

  • Loading branch information...
1 parent 4cedc44 commit 91bf162fa6454c1c959af7bdba27d823437106bf @xdg xdg committed Feb 10, 2012
Showing with 17 additions and 10 deletions.
  1. +17 −10 cookbooks/carton/providers/app.rb
@@ -22,6 +22,7 @@
require 'chef/mixin/language'
include Chef::Mixin::ShellOut
+
action :create do
# XXX should probably fail if no carton.lock is found in cwd
@@ -45,19 +46,25 @@
carton_perlbrew = app_perlbrew || node['carton']['perlbrew']
carton_lib = "#{carton_perlbrew}@carton"
- perlbrew_perl carton_perlbrew
- perlbrew_lib carton_lib
- perlbrew_run "cpanm Carton" do
- perlbrew carton_lib
- end
+ # If local directory for current carton.lock exists, skip
+ # carton install
+ unless ::File.exists?("#{app_cwd}/#{app_local}")
+ perlbrew_perl carton_perlbrew
+ perlbrew_lib carton_lib
+
+ perlbrew_run "cpanm Carton" do
+ perlbrew carton_lib
+ end
- perlbrew_run "carton install hello-world" do
- perlbrew carton_lib
- environment app_env
- cwd app_cwd
- command "carton install"
+ perlbrew_run "carton install hello-world" do
+ perlbrew carton_lib
+ environment app_env
+ cwd app_cwd
+ command "carton install"
+ end
end
+ # XXX should be idempotent
runit_service new_resource.name do
template_name 'carton-app'
cookbook 'carton'

0 comments on commit 91bf162

Please sign in to comment.