From f9927e4d9493b3c455c66d99b4546cdc478668d5 Mon Sep 17 00:00:00 2001 From: Jeremy Tan Date: Sat, 9 Sep 2017 15:53:14 +1000 Subject: [PATCH] Implement dynamic which/where for Windows Based on fontcustom/fontcustom#335 --- lib/fontcustom/base.rb | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/lib/fontcustom/base.rb b/lib/fontcustom/base.rb index e52f4fff..b0759ea8 100644 --- a/lib/fontcustom/base.rb +++ b/lib/fontcustom/base.rb @@ -13,6 +13,14 @@ def initialize(raw_options) @manifest = Fontcustom::Manifest.new(manifest, @options) end + def which + if !Gem.win_platform? + "which" + else # on windows + "where" + end + end + def compile current = checksum previous = @manifest.get(:checksum)[:previous] @@ -31,18 +39,14 @@ def compile private def check_fontforge - if !Gem.win_platform? - fontforge = `which fontforge` - else - fontforge = `where fontforge` - end + fontforge = `#{which} fontforge` if fontforge == "" || fontforge == "fontforge not found" raise Fontcustom::Error, "Please install fontforge first. Visit for instructions." end end def check_woff2 - woff2 = `which woff2_compress` + woff2 = `#{which} woff2_compress` if woff2 == "" || woff2 == "woff2_compress not found" fail Fontcustom::Error, "Please install woff2 first. Visit for instructions." end