From 845d529a50af33626eb0118b32b608898d2f08d7 Mon Sep 17 00:00:00 2001 From: Karl Freeman Date: Tue, 25 Mar 2014 08:21:53 +0000 Subject: [PATCH] don't load local templates if no HOME is set --- .../lib/middleman-templates.rb | 25 +++++++++++-------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/middleman-templates/lib/middleman-templates.rb b/middleman-templates/lib/middleman-templates.rb index 2e8a343c..65ca0a43 100644 --- a/middleman-templates/lib/middleman-templates.rb +++ b/middleman-templates/lib/middleman-templates.rb @@ -88,16 +88,19 @@ end # Register all official templates Dir.glob(File.expand_path('../middleman-templates/*.rb', __FILE__), &method(:require)) -# Iterate over directories in the templates path and register each one. -Dir[File.join(Middleman::Templates::Local.source_root, '*')].each do |dir| - next unless File.directory?(dir) - template_file = File.join(dir, 'template.rb') +# Sometimes HOME doesn't exist, in which case there's no point to local templates +if ENV['HOME'] + # Iterate over directories in the templates path and register each one. + Dir[File.join(Middleman::Templates::Local.source_root, '*')].each do |dir| + next unless File.directory?(dir) + template_file = File.join(dir, 'template.rb') - # If a template.rb file is found require it (therefore registering the template) - # else register the folder as a Local template (which when built, just copies the folder) - if File.exists?(template_file) - require template_file - else - Middleman::Templates.register(File.basename(dir).to_sym, Middleman::Templates::Local) + # If a template.rb file is found require it (therefore registering the template) + # else register the folder as a Local template (which when built, just copies the folder) + if File.exists?(template_file) + require template_file + else + Middleman::Templates.register(File.basename(dir).to_sym, Middleman::Templates::Local) + end end -end +end \ No newline at end of file