lib/pdk/generate/module.rb in pdk-1.6.0 vs lib/pdk/generate/module.rb in pdk-1.6.1
- old
+ new
@@ -52,21 +52,25 @@
prepare_module_directory(temp_target_dir)
template_url = opts.fetch(:'template-url', PDK::Util.default_template_url)
- PDK::Module::TemplateDir.new(template_url, metadata.data, true) do |templates|
- templates.render do |file_path, file_content|
- file = Pathname.new(temp_target_dir) + file_path
- file.dirname.mkpath
- file.write(file_content)
- end
+ begin
+ PDK::Module::TemplateDir.new(template_url, metadata.data, true) do |templates|
+ templates.render do |file_path, file_content|
+ file = Pathname.new(temp_target_dir) + file_path
+ file.dirname.mkpath
+ file.write(file_content)
+ end
- # Add information about the template used to generate the module to the
- # metadata (for a future update command).
- metadata.update!(templates.metadata)
+ # Add information about the template used to generate the module to the
+ # metadata (for a future update command).
+ metadata.update!(templates.metadata)
- metadata.write!(File.join(temp_target_dir, 'metadata.json'))
+ metadata.write!(File.join(temp_target_dir, 'metadata.json'))
+ end
+ rescue ArgumentError => e
+ raise PDK::CLI::ExitWithError, e
end
if template_url == PDK::Util.puppetlabs_template_url
# If the user specifies our template via the command line, remove the
# saved template-url answer.