Skip to content

Commit

Permalink
[ADDED] Find the install path for sbt, cargo and composer [#171649609]
Browse files Browse the repository at this point in the history
Signed-off-by: Jeff Jun <jjun@pivotal.io>
  • Loading branch information
pivotal-pmital authored and Milton committed Apr 27, 2020
1 parent 6851d7a commit 0d525cb
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
3 changes: 2 additions & 1 deletion lib/license_finder/package_managers/cargo.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ module LicenseFinder
class Cargo < PackageManager
def current_packages
cargo_output.map do |package|
CargoPackage.new(package, logger: logger)
path = Dir.glob("#{Dir.home}/.cargo/registry/src/**/#{package['name']}-#{package['version']}").first
CargoPackage.new(package, logger: logger, install_path: path)
end
end

Expand Down
6 changes: 5 additions & 1 deletion lib/license_finder/package_managers/composer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,11 @@ def possible_package_paths

def current_packages
dependency_list.map do |name, dependency|
ComposerPackage.new(name, dependency['version'], spec_licenses: dependency['license'])
path_command = "composer show #{name} -P"
stdout, _stderr, status = Dir.chdir(project_path) { Cmd.run(path_command) }

path = status.success? ? stdout.split(' ').last : ''
ComposerPackage.new(name, dependency['version'], spec_licenses: dependency['license'], install_path: path)
end
end

Expand Down
4 changes: 3 additions & 1 deletion lib/license_finder/package_managers/sbt.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,9 @@ def current_packages
'version' => version,
'licenses' => [{ 'name' => row['License'] }]
}
SbtPackage.new(spec, logger: logger, include_groups: @include_groups)

path = File.join("#{Dir.home}/.ivy2/cache", "#{spec['groupId']}/#{spec['artifactId']}")
SbtPackage.new(spec, logger: logger, include_groups: @include_groups, install_path: path)
end
end

Expand Down

0 comments on commit 0d525cb

Please sign in to comment.