Skip to content

Commit

Permalink
Merge pull request #10 from dkocic/dkocic-patch-1
Browse files Browse the repository at this point in the history
Fixing command existence detection on Windows.
  • Loading branch information
owahab committed Jun 5, 2015
2 parents e2e415f + 3ecbabc commit 6a1a893
Showing 1 changed file with 9 additions and 1 deletion.
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

0 comments on commit 6a1a893

Please sign in to comment.