@@ -17,7 +17,7 @@ def self.run(flags, input_file, output_file)
1717 # What is the OS and architecture specific executable name?
1818 exe_name = WebpExec . exe_name
1919
20- # We need to locate the Gems bin path as we're currently running inside the
20+ # We need to locate the Gems bin path as we're currently running inside the
2121 # jekyll site working directory
2222 # http://stackoverflow.com/a/10083594/779521
2323 gem_spec = Gem ::Specification . find_by_name ( "jekyll-webp" )
@@ -27,13 +27,25 @@ def self.run(flags, input_file, output_file)
2727 full_path = File . join ( gem_root , bin_path , exe_name )
2828
2929 # Construct the full program call
30- cmd = "\" #{ full_path } \" -quiet -mt \" #{ flags } \" \" #{ input_file } \" -o \" #{ output_file } \" "
31-
30+ cmd = "\" #{ full_path } \" -quiet -mt #{ flags } \" #{ input_file } \" -o \" #{ output_file } \" "
31+
3232 # Execute the command
33- stdin , stdout , stderr = Open3 . popen3 ( cmd )
33+ exit_code = 0
34+ error = ""
35+ output = ""
36+ Open3 . popen3 ( cmd ) do |stdin , stdout , stderr , wait_thr |
37+ stdin . close # wo don't pass any input to the process
38+ output = stdout . gets
39+ error = stderr . gets
40+ exit_code = wait_thr . value
41+ end
42+
43+ if exit_code != 0
44+ Jekyll . logger . error ( "WebP:" , "cwebp returned #{ exit_code } with error #{ error } " )
45+ end
3446
3547 # Return any captured return value
36- return [ stdin , stdout , stderr ]
48+ return [ output , error ]
3749 end #function run
3850
3951 #
@@ -60,7 +72,7 @@ def self.exe_name
6072 end #function exe_name
6173
6274 end #class WebpExec
63-
75+
6476 end #module Webp
6577
6678 module OS
0 commit comments