summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authormo khan <mo.khan@gmail.com>2020-11-18 11:57:01 -0700
committermo khan <mo.khan@gmail.com>2020-11-18 12:27:36 -0700
commit7e522b58a2859f60b682fce4bd2c6a2d20238468 (patch)
tree756e978f5f119ca7ceb641e7ee54a5491f8c092e /lib
parent8ac6eb1827c032692c7df5cefaa15ec7272952dc (diff)
feat: rebuild index during pull command
Diffstat (limited to 'lib')
-rw-r--r--lib/spandx/cli/commands/pull.rb5
-rw-r--r--lib/spandx/core/cache.rb3
-rw-r--r--lib/spandx/core/data_file.rb4
3 files changed, 11 insertions, 1 deletions
diff --git a/lib/spandx/cli/commands/pull.rb b/lib/spandx/cli/commands/pull.rb
index c749016..67c1c43 100644
--- a/lib/spandx/cli/commands/pull.rb
+++ b/lib/spandx/cli/commands/pull.rb
@@ -13,6 +13,11 @@ module Spandx
output.puts "Updating #{db.url}..."
db.update!
end
+ Spandx::Core::Dependency::PACKAGE_MANAGERS.values.uniq.each do |type|
+ Spandx::Core::Cache
+ .new(type, root: Spandx.git[:cache].root.join('.index'))
+ .rebuild_index(output: output)
+ end
output.puts 'OK'
end
end
diff --git a/lib/spandx/core/cache.rb b/lib/spandx/core/cache.rb
index 528e182..817451b 100644
--- a/lib/spandx/core/cache.rb
+++ b/lib/spandx/core/cache.rb
@@ -43,8 +43,9 @@ module Spandx
datafiles.fetch(key_for(name))
end
- def rebuild_index
+ def rebuild_index(output: $stderr)
datafiles.each do |_hex, datafile|
+ output.puts "Rebuilding #{datafile}..."
datafile.index.update!
end
end
diff --git a/lib/spandx/core/data_file.rb b/lib/spandx/core/data_file.rb
index 1ed88ea..827f4e0 100644
--- a/lib/spandx/core/data_file.rb
+++ b/lib/spandx/core/data_file.rb
@@ -56,6 +56,10 @@ module Spandx
@index ||= IndexFile.new(self)
end
+ def to_s
+ absolute_path.to_s
+ end
+
private
def to_csv(array)