From 3ecbabc2a1dc5301cfb457d65e0c48ffa864e51b Mon Sep 17 00:00:00 2001 From: dkocic Date: Tue, 2 Jun 2015 21:15:22 +0200 Subject: [PATCH] Fixing command existence detection on Windows. --- lib/av/cli.rb | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/lib/av/cli.rb b/lib/av/cli.rb index 5f042ea..7b1c69f 100644 --- a/lib/av/cli.rb +++ b/lib/av/cli.rb @@ -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/ @@ -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