204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
|
# File 'lib/modulesync.rb', line 204
def self.execute(cli_options)
@options = config_defaults.merge(cli_options)
errors = {}
managed_modules.each do |puppet_module|
$stdout.puts "#{puppet_module.given_name}:"
puppet_module.repository.clone unless puppet_module.repository.cloned?
if @options[:default_branch]
puppet_module.repository.switch branch: false
else
puppet_module.repository.switch branch: @options[:branch]
end
command_args = cli_options[:command_args]
local_script = File.expand_path command_args[0]
command_args[0] = local_script if File.exist?(local_script)
command_env = ENV.reject { |k, _v| k.match?(/(^BUNDLE|^SOURCE_DATE_EPOCH$|^GEM_|RUBY)/) }
result = system command_env, *command_args, unsetenv_others: true, chdir: puppet_module.working_directory
unless result
message = "Command execution failed ('#{@options[:command_args].join ' '}': #{$CHILD_STATUS})"
raise Thor::Error, message if @options[:fail_fast]
errors[puppet_module.given_name] = message
warn message
end
$stdout.puts ''
end
unless errors.empty?
raise Thor::Error, " Error(s) during `execute` command:\n \#{errors.map { |name, message| \" * \#{name}: \#{message}\" }.join \"\\n\"}\n MSG\n end\n\n exit 1 unless errors.empty?\nend\n"
|