Sha256: 19e076fff1145fd3beaf1e3495e4b3df2ce4f611bd88c78455fe99365bafcab6

Contents?: true

Size: 1.48 KB

Versions: 17

Compression:

Stored size: 1.48 KB

Contents

# frozen_string_literal: true

module LicenseFinder
  class Erlangmk < PackageManager
    def package_management_command
      'make'
    end

    def package_management_command_with_path
      "#{package_management_command} --directory=#{project_path} --no-print-directory"
    end

    # The IS_DEP=1 is added because not all erlang.mk-based projects are
    # updated to a version that is compatible with LicenseFinder
    def prepare_command
      "#{package_management_command_with_path} IS_DEP=1 fetch-deps"
    end

    def possible_package_paths
      [
        project_path.join('Erlang.mk'),
        project_path.join('erlang.mk')
      ]
    end

    def current_packages
      deps.map do |dep|
        ErlangmkPackage.new(dep)
      end
    end

    private

    def deps
      command = "#{package_management_command_with_path} QUERY='name fetch_method repo version absolute_path' query-deps"
      stdout, stderr, status = Cmd.run(command)
      if status.success?
        dep_re = Regexp.new('^\s*DEP')
        line_re = Regexp.new('^[_a-z0-9]+:')
        stdout.each_line.map(&:strip).select { |line| !(line.start_with?('make') || line =~ dep_re) && line =~ line_re }
      elsif stderr.include? "No rule to make target 'query-deps'"
        # The stderr check happens because not all erlang.mk-based projects are
        # updated to a version that is compatible with LicenseFinder
        []
      else
        raise "Command '#{command}' failed to execute: #{stderr}"
      end
    end
  end
end

Version data entries

17 entries across 17 versions & 2 rubygems

Version Path
license_finder-7.1.0 lib/license_finder/package_managers/erlangmk.rb
license_finder-7.0.1 lib/license_finder/package_managers/erlangmk.rb
license_finder-7.0.0 lib/license_finder/package_managers/erlangmk.rb
license_finder-6.15.0 lib/license_finder/package_managers/erlangmk.rb
gitlab-license_finder-6.14.2.1 lib/license_finder/package_managers/erlangmk.rb
license_finder-6.14.2 lib/license_finder/package_managers/erlangmk.rb
license_finder-6.14.1 lib/license_finder/package_managers/erlangmk.rb
license_finder-6.13.0 lib/license_finder/package_managers/erlangmk.rb
license_finder-6.12.2 lib/license_finder/package_managers/erlangmk.rb
license_finder-6.12.1 lib/license_finder/package_managers/erlangmk.rb
license_finder-6.12.0 lib/license_finder/package_managers/erlangmk.rb
license_finder-6.11.0 lib/license_finder/package_managers/erlangmk.rb
license_finder-6.10.1 lib/license_finder/package_managers/erlangmk.rb
license_finder-6.10.0 lib/license_finder/package_managers/erlangmk.rb
license_finder-6.9.0 lib/license_finder/package_managers/erlangmk.rb
license_finder-6.8.2 lib/license_finder/package_managers/erlangmk.rb
license_finder-6.8.1 lib/license_finder/package_managers/erlangmk.rb