Skip to content

Commit 6b8a8e1

Browse files
authored
Merge pull request #27 from bjgordon/master
Fixed so PATH modification doesnt error on windows
2 parents 126ebd3 + c05ace3 commit 6b8a8e1

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

lib/grim/image_magick_processor.rb

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
require 'open3'
2+
13
module Grim
24
class ImageMagickProcessor
35

@@ -40,11 +42,15 @@ def save(pdf, index, path, options)
4042
command << "#{Shellwords.shellescape(pdf.path)}[#{index}]"
4143
command << path
4244

43-
command.unshift("PATH=#{File.dirname(@ghostscript_path)}:#{ENV['PATH']}") if @ghostscript_path && @ghostscript_path != DefaultGhostScriptPath
45+
command_env = {}
4446

45-
result = `#{command.join(' ')}`
47+
if @ghostscript_path && @ghostscript_path != DefaultGhostScriptPath
48+
command_env['PATH'] = "#{File.dirname(@ghostscript_path)}#{File::PATH_SEPARATOR}#{ENV['PATH']}"
49+
end
50+
51+
result, status = Open3.capture2e(command_env, command.join(' '))
4652

47-
$? == 0 || raise(UnprocessablePage, result)
53+
status.success? || raise(UnprocessablePage, result)
4854
end
4955
end
5056
end

0 commit comments

Comments
 (0)