summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authormo khan <mo.khan@gmail.com>2020-05-14 15:33:37 -0600
committermo khan <mo.khan@gmail.com>2020-05-14 15:33:37 -0600
commit7d2b06dd3aa9ae1ab5489536a859108c5350717c (patch)
treeca572a9a4294db37fb3ec02fe5f1ce2570ec1218 /lib
parent021808e5008baca36be9eaa80558b1d1610127fa (diff)
Update command to work in all golang versions
Diffstat (limited to 'lib')
-rw-r--r--lib/license/finder/ext/go_modules.rb24
1 files changed, 4 insertions, 20 deletions
diff --git a/lib/license/finder/ext/go_modules.rb b/lib/license/finder/ext/go_modules.rb
index f37519c..41bac11 100644
--- a/lib/license/finder/ext/go_modules.rb
+++ b/lib/license/finder/ext/go_modules.rb
@@ -10,10 +10,12 @@ module LicenseFinder
end
def current_packages
- stdout, _stderr, status = shell.execute(command_for_current_version)
+ stdout, _stderr, status = shell.execute([
+ :go, :list, '-m', '-f', "'{{.Path}},{{.Version}},{{.Dir}}'", :all
+ ])
return [] unless status.success?
- stdout.lines.map do |line|
+ stdout.each_line.map do |line|
name, version, dir = line.chomp.split(',')
next if dir.nil?
next if Pathname(dir).cleanpath == absolute_project_path
@@ -24,24 +26,6 @@ module LicenseFinder
private
- def command_for_current_version
- format = "'{{.Path}},{{.Version}},{{.Dir}}'"
- case go_version
- when '1.11'
- [:go, :list, '-m', '-mod=vendor', '-f', format, :all]
- when '1.12'
- [:go, :list, '-m', '-mod=vendor', '-f', format, :all]
- when '1.13'
- [:go, :list, '-m', '-mod=vendor', '-f', format, :all]
- else
- [:go, :list, '-m', '-mod=readonly', '-f', format, :all]
- end
- end
-
- def go_version
- `go version`.scan(/\sgo(?<version>\d\.\d{1,2})\s/)
- end
-
def absolute_project_path
@absolute_project_path ||= Pathname(project_path).cleanpath
end