Skip to content

Commit 883f40b

Browse files
Fix default file creation on windows
1 parent 9bff81b commit 883f40b

3 files changed

Lines changed: 24 additions & 97 deletions

File tree

lib/workup/application.rb

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,19 @@ def initialize(*args)
4444
super(*args)
4545
end
4646

47+
no_commands do
48+
def chef_lib(description)
49+
log.info description
50+
return_code = Workup::Helpers.silence { yield }
51+
if return_code.zero?
52+
log.debug "OK\n"
53+
else
54+
log.error "Failure\n"
55+
exit return_code
56+
end
57+
end
58+
end
59+
4760
desc 'default', 'Default task'
4861
def default
4962
chef_zero
@@ -53,19 +66,16 @@ def default
5366
desc 'chef_zero', 'Create the chef-zero directory'
5467
def chef_zero
5568
Workup::Helpers.initialize_files(options[:workup_dir])
56-
5769
policy_path = File.join(options[:workup_dir], 'Policyfile.rb')
5870
chefzero_path = File.join(options[:workup_dir], 'chef-zero')
5971

60-
log.info 'Updating lock file... '
61-
Workup::Helpers.silence { ChefDK::Command::Update.new.run([policy_path]) }
62-
log.debug "OK\n"
72+
chef_lib('Updating lock file... ') do
73+
ChefDK::Command::Update.new.run([policy_path])
74+
end
6375

64-
log.info 'Creating chef-zero directory... '
65-
Workup::Helpers.silence do
76+
chef_lib('Creating chef-zero directory... ') do
6677
ChefDK::Command::Export.new.run(['--force', policy_path, chefzero_path])
6778
end
68-
log.debug "OK\n"
6979
end
7080

7181
desc 'workup', 'Run workup'

lib/workup/helpers.rb

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -55,11 +55,13 @@ def chef_client(client_rb, dry_run = false)
5555
end
5656

5757
def chef_apply(recipe, dry_run = false)
58-
cmd = [chef_bin('chef-apply'),
59-
'--log_level', 'fatal',
60-
'--minimal-ohai',
61-
'--execute', recipe]
58+
cmd = [chef_bin('chef-apply'), '--log_level', 'fatal', '--minimal-ohai']
6259
cmd << '--why-run' if dry_run
60+
if Gem.win_platform?
61+
cmd.concat(['--execute', "\"#{recipe.gsub(/\n/, ';')}\""])
62+
else
63+
cmd.concat(['--execute', recipe])
64+
end
6365

6466
execute(*cmd, live_stdout: STDOUT, live_stderr: STDERR)
6567
end
@@ -73,7 +75,7 @@ def initialize_files(workup_dir)
7375
.each do |f|
7476
chef_apply %(file '#{File.join(workup_dir, File.basename(f))}' do
7577
action :create_if_missing
76-
content %q(#{IO.read(f)})
78+
content IO.read('#{f}')
7779
end)
7880
end
7981
end

omnibus/Gemfile.lock

Lines changed: 0 additions & 85 deletions
This file was deleted.

0 commit comments

Comments
 (0)