Method: RBS::Collection::Sources::Local#install

Defined in:
lib/rbs/collection/sources/local.rb

#install(dest:, name:, version:, stdout:) ⇒ Object

Create a symlink instead of copying file to refer files in @path. By avoiding copying RBS files, the users do not need re-run ‘rbs collection install` when the RBS files are updated.



32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# File 'lib/rbs/collection/sources/local.rb', line 32

def install(dest:, name:, version:, stdout:)
  from = @full_path.join(name, version)
  gem_dir = dest.join(name, version)

  case
  when gem_dir.symlink? && gem_dir.readlink == from
    stdout.puts "Using #{name}:#{version} (#{from})"
  when gem_dir.symlink?
    prev = gem_dir.readlink
    gem_dir.unlink
    _install(from, dest.join(name, version))
    stdout.puts "Updating #{name}:#{version} to #{from} from #{prev}"
  when gem_dir.directory?
    # TODO: Show version of git source
    FileUtils.remove_entry_secure(gem_dir.to_s)
    _install(from, dest.join(name, version))
    stdout.puts "Updating #{name}:#{version} from git source"
  when !gem_dir.exist?
    _install(from, dest.join(name, version))
    stdout.puts "Installing #{name}:#{version} (#{from})"
  else
    raise
  end
end