Class: LicenseFinder::GoModules

Inherits:
PackageManager show all
Defined in:
lib/license_finder/package_managers/go_modules.rb

Constant Summary collapse

PACKAGES_FILE =
'go.sum'

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from PackageManager

command_exists?, #current_packages_with_relations, #detected_package_path, #initialize, installed?, package_management_command, #prepare, #project_root?

Constructor Details

This class inherits a constructor from LicenseFinder::PackageManager

Class Method Details

.takes_priority_overObject



10
11
12
# File 'lib/license_finder/package_managers/go_modules.rb', line 10

def takes_priority_over
  Go15VendorExperiment
end

Instance Method Details

#active?Boolean

Returns:

  • (Boolean)


19
20
21
# File 'lib/license_finder/package_managers/go_modules.rb', line 19

def active?
  sum_files?
end

#current_packagesObject



23
24
25
26
27
28
29
30
31
32
33
# File 'lib/license_finder/package_managers/go_modules.rb', line 23

def current_packages
  info_output, _stderr, _status = Cmd.run("GO111MODULE=on go list -m -mod=vendor -f '{{.Path}},{{.Version}},{{.Dir}}' all")
  packages_info = info_output.split("\n")
  packages = packages_info.map do |package|
    name, version, install_path = package.split(',')
    read_package(install_path, name, version)
  end
  packages.reject do |package|
    Pathname(package.install_path).cleanpath == Pathname(project_path).cleanpath
  end
end

#prepare_commandObject



15
16
17
# File 'lib/license_finder/package_managers/go_modules.rb', line 15

def prepare_command
  'GO111MODULE=on go mod tidy && GO111MODULE=on go mod vendor'
end