Class: LicenseFinder::Mix
Class Method Summary
collapse
Instance Method Summary
collapse
#active?, command_exists?, #current_packages_with_relations, #detected_package_path, installed?, #prepare, takes_priority_over
Constructor Details
#initialize(options = {}) ⇒ Mix
Returns a new instance of Mix.
5
6
7
8
9
|
# File 'lib/license_finder/package_managers/mix.rb', line 5
def initialize(options = {})
super
@command = options[:mix_command] || Mix.package_management_command
@deps_path = Pathname(options[:mix_deps_dir] || 'deps')
end
|
Class Method Details
.package_management_command ⇒ Object
36
37
38
|
# File 'lib/license_finder/package_managers/mix.rb', line 36
def self.package_management_command
'mix'
end
|
.prepare_command ⇒ Object
40
41
42
|
# File 'lib/license_finder/package_managers/mix.rb', line 40
def self.prepare_command
'mix deps.get'
end
|
Instance Method Details
#current_packages ⇒ Object
11
12
13
14
15
16
17
18
19
20
21
|
# File 'lib/license_finder/package_managers/mix.rb', line 11
def current_packages
mix_output.map do |name, version|
MixPackage.new(
name,
version,
install_path: @deps_path.join(name),
logger: logger,
spec_licenses: licenses(name)
)
end
end
|
#licenses(name) ⇒ Object
24
25
26
27
28
29
30
31
32
33
34
|
# File 'lib/license_finder/package_managers/mix.rb', line 24
def licenses(name)
config_path = @deps_path.join(name).join('hex_metadata.config')
args = "\\\"#{config_path}\\\" |> :file.consult() |> case do {:ok, metadata} -> metadata; {:error, _} -> [] end |> List.keyfind(\\\"licenses\\\", 0) |> case do {_, licenses} -> licenses; _ -> [] end |> Enum.join(\\\"\\t\\\") |> IO.puts()"
command = "#{@command} run --no-start --no-compile -e \"#{args}\""
stdout, stderr, status = Dir.chdir(project_path) { Cmd.run(command) }
raise "Command '#{command}' failed to execute: #{stderr}" unless status.success?
stdout.strip.split("\t")
end
|
#possible_package_paths ⇒ Object
44
45
46
|
# File 'lib/license_finder/package_managers/mix.rb', line 44
def possible_package_paths
[project_path.join('mix.exs')]
end
|