Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion lib/av/cli.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def method_missing name, *args, &block
end

def detect_command(command)
command = "if command -v #{command} 2>/dev/null; then echo \"true\"; else echo \"false\"; fi"
command = self.system_based_detect_command(command)
result = ::Av.run(command)
case result
when /true/
Expand All @@ -29,5 +29,13 @@ def detect_command(command)
return false
end
end

def system_based_detect_command(command)
if Gem.win_platform?
"#{command} -version 2>NUL && echo true || echo false"
else
"if command -v #{command} 2>/dev/null; then echo \"true\"; else echo \"false\"; fi"
end
end
end
end