seattlerb / hoe

Hoe is a rake/rubygems helper for project Rakefiles. It helps you manage, maintain, and release your project and includes a dynamic plug-in system allowing for easy extensibility. Hoe ships with plug-ins for all your usual project tasks including rdoc generation, testing, packaging, deployment, and announcement.

Home Page:http://www.zenspider.com/projects/hoe.html

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Nested module directory creation fails

chriscz opened this issue · comments

Part of my template looks as follows:

lib/file_name.rb
lib/file_name/

When I run sow foo-bar there's an error because the intermediary directory lib/foo in lib/foo/bar wasn't created.

I added FileUtils.mkdir_p for directories to sow on line 105 & 110:

diff --git a/bin/sow b/bin/sow
index 10de657..182e7b8 100755
--- a/bin/sow
+++ b/bin/sow
@@ -102,11 +102,13 @@ FileUtils.cp_r template_path, project
 Dir.chdir project do
   dirs = Dir["**/*"].select { |f| File.directory? f }.sort.reverse
   dirs.grep(/file_name$/).each do |file|
+    FileUtils.mkdir_p File.dirname(file.sub(/file_name$/, file_name))
     FileUtils.mv file, file.sub(/file_name$/, file_name)
   end
 
   dirs = Dir["**/*"].select { |f| File.directory? f }.sort.reverse
   dirs.grep(/ext_name$/).each do |file|
+    FileUtils.mkdir_p File.dirname(file.sub(/ext_name$/, ext_name))
     FileUtils.mv file, file.sub(/ext_name$/, ext_name)
   end

Would you consider adding this fix?

I'm getting confused by my own shitty ancient code... Why do those two paragraphs even exist if this is below:

https://github.com/seattlerb/hoe/blob/master/bin/sow#L149-L150

Bit and brain rot 😄

Hmm, it looks like those are only applicable to files ending in .erb, might be better to hoist it or create a helper for file creation? 🤷

I've applied your diffs above. (I don't remember the last time I actually used sow at this point? when did I last start a new project? SAD!)... I'll get a release out shortly

Sigh, yeah I've not used sow much myself, but was looking to iron out my local project creation process and have a single tool. At the moment using bundler or rails, but the options for templating out there are few it seems, maybe I haven't looked hard enough!