Browse Source

Make sure the directory is a ports directory

Douglas Thrift 5 years ago
parent
commit
27c5059970
1 changed files with 5 additions and 3 deletions
  1. 5 3
      Rakefile

+ 5 - 3
Rakefile

@@ -13,8 +13,10 @@ require 'set'
 Color = Pry::Helpers::Text
 
 def in_portdir(&block)
-  Dir.chdir(Rake.original_dir) do |portdir|
-    block.call(Pathname.new(portdir))
+  portdir = Pathname.new(Rake.original_dir)
+  raise "#{portdir} is not a port directory" unless portdir.relative_path_from(@portsdir).to_s =~ %r{[^/]+/[^/]+}
+  Dir.chdir(portdir) do
+    block.call(portdir)
   end
 end
 
@@ -42,7 +44,7 @@ def update_portstree_map(map = {})
 end
 
 portstree_map = update_portstree_map
-portsdir = Pathname.pwd
+portsdir = @portsdir = Pathname.pwd
 distdir = portsdir.join('distfiles')
 
 task default: %i(update_githead update_svnhead)